I've got this query:
$wd=1.5480;
$query = "UPDATE books SET myprice= myprice + $wd";
The query fails almost 1 in 10 times. There is no obvious pattern I can spot.
The column I try to update is a float. The value varies from 0 to 9.99999.
I've set the error log to report the error in the query, and display the query itself.
I've got this error in error log:
Database Error: 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 '=+1'
at line 1<br/><br/>
Query:UPDATE books SET =+1
As you can see the myprice is missing from the query. What am I doing wrong?
Thanks in advance for your help.
Try with this:
$query = "UPDATE books SET `myprice` = `myprice`+".$wd;
you missed $ infront of myprice variable that might be the reason
try this:
$query = "UPDATE `books` SET `myprice` = `myprice` + $wd";
Try to replace " by ' to avoid unwanted var interpretation, and use sprintf() for query construction :
$query = sprintf('UPDATE books SET myprice = myprice + %s', $wd);
Could you try this:
$query = "UPDATE `books` SET `myprice` = `myprice` + $wd";
Try this,
$wd=1.5480;
$query = "UPDATE books SET `myprice` = `myprice` + {$wd}";