问题描述:

code :

mysql_connect('localhost','root','root');

mysql_select_db('share_counter');

$sql_insert = "UPDATE wpshare SET '$social_name'='45' where post_title = '$post_title' ";

mysql_query($sql_insert) or die(mysql_error());

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

''twitter_count'='45' where post_title

= 'test'' at line 1

thanks advance

网友答案:

omit the quotes over $social_name

$sql_insert = "UPDATE wpshare SET $social_name='45' where post_title = '$post_title' ";
网友答案:

quotes around the column names (aka $social_name) should be like this ` not like this '

so $sql_insert = "UPDATE wpshare SET `$social_name`='45' where post_title = '$post_title' ";

and if your column names have no spaces , you can just remove the quotes ...

网友答案:
$sql_insert = "UPDATE `wpshare` SET `$social_name`='45' WHERE `post_title` = '$post_title'";
相关阅读:
Top