Hi,
I'm using MySQL with php3 and I encountered a problem when trying to update the DB using an update string like this -
$update_sql_str = "UPDATE table SET field='$string' WHERE id = $id ";
Now, the problem is that $string is a variable containing a string that has both 's and "s in it so I keep getting "You have an error in your SQL syntax near..." since the SQL query thinks the data for field ends before it really does.
For example, if $string = Joe said "it's a beatiful day"
then if I use the above syntax, it thinks that field is only [Joe said "it] and if I use SET string="$string", it thinks that field is only [Joe said ].
Is there another syntax I can use?
Thanks.
I'm using MySQL with php3 and I encountered a problem when trying to update the DB using an update string like this -
$update_sql_str = "UPDATE table SET field='$string' WHERE id = $id ";
Now, the problem is that $string is a variable containing a string that has both 's and "s in it so I keep getting "You have an error in your SQL syntax near..." since the SQL query thinks the data for field ends before it really does.
For example, if $string = Joe said "it's a beatiful day"
then if I use the above syntax, it thinks that field is only [Joe said "it] and if I use SET string="$string", it thinks that field is only [Joe said ].
Is there another syntax I can use?
Thanks.