I’ve encountered an error when uploading an application from my local machine to a development server. I’m attempting to insert a record into a table which works locally (WAMP, PHP 5.4.3, MySQL 5.5.24) but it fails on the development server (IIS, PHP 5.3.2, MySQL 5.0.88).
My query is:
$SQL="INSERT INTO log(`dev_id`,`website_id`,`time_entered`,`location`,`page`,`reason`,`backup_file`,`status`) VALUES('".$DevID."','".$WebsiteID."','".time()."','".$Location."','".$Page."','".$Reason."','".$BackupFile."','".$Status."')";
As you can see I’ve backticked the fields, because I thought it was that. I also quoted everything because I thought the unquoted numbers were causing the issue. I have also turned this into a prepared statement and have gotten the same error which is:
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 'log(`dev_id`,`website_id`,`time_entered`,`location`,`page`,`reason`,`backup_file' at line 1
I’ve looked all around for a solution and it seems that error 1064 is a tricky one. I’m assuming it has to do with the massive difference in software versions.
Table names that are reserved keywords need to be escaped, too.
What you’ve done there is akin to making a call to the LOG function.