MySQL错误更新数据库时

时间:2013-01-09 14:18:39

标签: php mysql

$column = "`0907001`='0',`0907002`='0',`0907003`='0',`0907004`='0',`0907005`='0'";
$date="01/01/2013";   
$sql_cmd = "UPDATE `$database`.`$table` SET ($column) WHERE `$table`.`Date` = '$date'";
if(!mysql_query($sql_cmd)) {
  die('inside AddUserToDataBase Error: ' . mysql_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 '(`0907001`='0',`0907002`='0',`0907003`='0',`0907004`='0',`0907005`='0') WHERE `C' at line 1

请帮助.... 我怎样才能解决这个问题........

2 个答案:

答案 0 :(得分:2)

只需将( )放在查询中$columns左右:

$sql_cmd = "UPDATE `$database`.`$table` SET $column WHERE `$table`.`Date` = '$date'";

答案 1 :(得分:1)

删除列周围的括号。而不是:

UPDATE TABLE table SET (column = value)

应该是

UPDATE TABLE table SET column = value