ERROR TO SAVE DATA TO ANOTHER TABLE {HELP}

Hi guy
i’m getting this error to save data into another table please help
user using comma ’ in between the field

ERROR
Error while accessing the database:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '‘s trading corporation , admin, ‘2011-11-22 12:47:19’)’ at line 1

View SQL

Re: ERROR TO SAVE DATA TO ANOTHER TABLE {HELP}

this is the code im using …

sc_exec_sql("INSERT INTO clients_history (client_id, field_id, value, user, last_updated)
			VALUES ({cust_id}, 35, '{cust_comments}', [userid], '$current_date')");

Re: ERROR TO SAVE DATA TO ANOTHER TABLE {HELP}

Hi.
The string fields must have quotation marks, the number fields don?t.
If your Client_id field is string type, then you must write like this … VALUES ( ‘{cust_id}’, 35, …

JG

Re: ERROR TO SAVE DATA TO ANOTHER TABLE {HELP}

rest is ok but the problem is only with {cust_comments}

user can enter the comma ’ and after that getting error to save in other table.
hope you understand…
thanks

Re: ERROR TO SAVE DATA TO ANOTHER TABLE {HELP}

perhaps something like:


$sql = 'INSERT INTO clients_history (client_id, field_id, value, user, last_updated)';
$sql .= ' VALUES (';
$sql .= ' {cust_id}, 35, "{cust_comments}", [userid], "$current_date")';

or 

$sql .= ' {cust_id}, 35, " '.{cust_comments}.' ", [userid], " '.$current_date.' ")';

sc_exec_sql($sql);

Regards,
Scott.