Why is it, that I can’t UPDATE a field (type:longtext) with a string that contains a comma (,)…
$result=mysql_query("UPDATE table_name SET column1=$a WHERE column2=$b AND column3='price'");
Works well with
$a="10"; or $a="10.99";
$b="15";
doesn’t work with
$a="10,99";
$b="15";
neither works with:
$a="10,99";
$a=mysql_real_escape_string($a);
What am I doing wrong here?
When your query string is being evaluated with the values that contain commas, this is the query:
"UPDATE table_name SET column1=10,19 WHERE column2=15 AND column3='price'";The comma is creating an issue because the value 10,19 is not a string. You need to put quotes around your variables. If you use double-quotes, you will need to escape the quotes. Single quotes work as well; either of the following should do the trick:
or