#26855 [NEW]: UPDATE query unexplicable behavior

From: Date: Fri, 09 Jan 2004 18:44:54 +0000
Subject: #26855 [NEW]: UPDATE query unexplicable behavior
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-53041@lists.php.net to get a copy of this message
From: superzouz at hotmail dot com Operating system: various PHP version: 4.3.4 PHP Bug Type: MySQL related Bug description: UPDATE query unexplicable behavior Description: ------------ When I run the following query through PHP: UPDATE config_intranet SET confvalue = '192.168.0.1' WHERE confkey 'vpn_server_ip' I get the following error. 1064: You have an error in your SQL syntax near 'query' at line 1 But if I type the same query directly into MySQL, it is executed correctly! I was able to reproduce this situation on my PC (Windows XP SP1) with PHP 4.3.4 and MySQL "client api version 3.23.49", and on 2 internet hosting providers running PHP 4.x with mySql on *nix systems, so it is not an issue with my configuration. There is nothing in the official PHP docs stating that a query would be handled differently by PHP and MySQL. Thanks Reproduce code: --------------- $conn = mysql_connect ( "localhost", "rolfen" , "" ); mysql_select_db("dergham", $conn); $query = mysql_real_escape_string("UPDATE config_intranet SET confvalue = '192.168.0.1' WHERE confkey = 'vpn_server_ip'"); $res = mysql_query(query, $conn); if ($res) echo "success"; else { die("Error while updating config table. Error Output: <br/>". mysql_errno() . ": " . mysql_error(). "<br/>"."Query follows:<br/>".$query); return False; } ?> Expected result: ---------------- success Actual result: -------------- Content-type: text/html X-Powered-By: PHP/4.3.2 X-Powered-By: PHP/4.3.2 Content-type: text/html Error while updating config table. Error Output: <br/>1064: You have an error in your SQL syntax near 'query' at line 1<br/>Query follows:<br/>UPDATE config_intranet SET confvalue = \'192.168.0.1\' WHERE confkey = \'vpn_server_ip\' -- Edit bug report at http://bugs.php.net/?id=26855&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26855&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26855&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26855&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26855&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26855&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=26855&r=needscript Try newer version: http://bugs.php.net/fix.php?id=26855&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=26855&r=support Expected behavior: http://bugs.php.net/fix.php?id=26855&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=26855&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=26855&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26855&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26855&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26855&r=dst IIS Stability: http://bugs.php.net/fix.php?id=26855&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=26855&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26855&r=float

« previous php.bugs (#53041) next »