Berbatov
Berbatov

Reputation: 1063

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

Upvotes: 2

Views: 86

Answers (3)

Php developer
Php developer

Reputation: 456

if you are putting single quotes on the field name it will show error, don't get confused in single quotes and backticks they are completely different.

Upvotes: 0

Nisarg
Nisarg

Reputation: 3252

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

USE cron Not 'cron'

Upvotes: 2

Mahmoud Gamal
Mahmoud Gamal

Reputation: 79929

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 (``).

Upvotes: 5

Related Questions