Friday, March 9, 2018

php - Error when running MySQL query, looking for right syntax



I get the following error when running my .php file:




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 ''feeds_list' SET 'cron' = now() WHERE 'feed_id' = '1'' at line 1




Here is the code:



$sql = mysql_query("UPDATE 'feeds_list' SET 'cron' = now() WHERE 'feed_id' = '$feed_id'") or die (mysql_error());


Thanks for helping me out


Answer




Remove the '' around table names and column names, it should be:



UPDATE feeds_list SET cron = now() WHERE feed_id = '$feed_id'


or use a backticks (``).


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...