Problem with PHP / MySQL codes

Hello guys,

I have an issue with single quotes in my data

$Query = “INSERT INTO customer (surname, first_name, full_name, dob, address, …)
VALUES
(’{cus_surname}’, ‘{cus_first_name}’, ‘{cus_name}’, ‘{cus_dob}’, ‘{cus_address}’ , …)”;
sc_exec_sql($Query);

I get error when the address field contains single quote e.g L’Escale Bouchon.

Any solution?

$v_surname = addslashes({cus_surname});
$v_first_name = addslashes({cus_first_name});

$Query = “INSERT INTO customer (surname, first_name, …)
VALUES
(’$v_surname’, ‘v_first_name’, …)”;
sc_exec_sql($Query);

1 Like

Thanks, @robydago
addslashes() worked for me.