crawlerbasher Posted May 20, 2010 Share Posted May 20, 2010 I'm trying to update my database but keep getting this 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 ''Title' = 'Testing today', 'Story' = 'This' WHERE 'id' = ''' at line 1 I can't seem to find whats causing the problem. This is the code. $id = $_POST['id']; $Story = $_POST['Story']; $Title = $_POST['Title']; mysql_query("UPDATE TaruNews SET 'Title' = '$Title', 'Story' = '$Story' WHERE 'id' = '$id'")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/202326-update-mysql-database-php-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 20, 2010 Share Posted May 20, 2010 String data is enclosed in single-quotes, making them strings. Column names are not. Quote Link to comment https://forums.phpfreaks.com/topic/202326-update-mysql-database-php-error/#findComment-1060892 Share on other sites More sharing options...
-Karl- Posted May 20, 2010 Share Posted May 20, 2010 mysql_query("UPDATE TaruNews SET `Title` = '$Title', `Story` = '$Story' WHERE `id` = '$id'")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/202326-update-mysql-database-php-error/#findComment-1060893 Share on other sites More sharing options...
crawlerbasher Posted May 20, 2010 Author Share Posted May 20, 2010 I've tried that and get no error messages now. But now its just not updating it. I've checked it to make sure that the tables name are the same in the script and that the casing match too. Quote Link to comment https://forums.phpfreaks.com/topic/202326-update-mysql-database-php-error/#findComment-1060898 Share on other sites More sharing options...
-Karl- Posted May 20, 2010 Share Posted May 20, 2010 Echo the query, make sure all the information you expect to be there, is actually there. (id, Title, etc) Quote Link to comment https://forums.phpfreaks.com/topic/202326-update-mysql-database-php-error/#findComment-1060899 Share on other sites More sharing options...
crawlerbasher Posted May 20, 2010 Author Share Posted May 20, 2010 when I echo it, all I get is 1 Quote Link to comment https://forums.phpfreaks.com/topic/202326-update-mysql-database-php-error/#findComment-1060900 Share on other sites More sharing options...
crawlerbasher Posted May 20, 2010 Author Share Posted May 20, 2010 ok got it working now, thank you. Quote Link to comment https://forums.phpfreaks.com/topic/202326-update-mysql-database-php-error/#findComment-1060903 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.