0

我正在尝试一次更新多个列:

  $query="UPDATE search_page
     SET search_page_description='".$search_page_description."',
     SET title='".$title."',
     SET h1='".$h1."',
     SET meta_description='".$metadata."'
     WHERE features_id=".$id;
     $result_update_query=databaseConn :: dbDelta($query);

我明白了:

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 'SET title='fasdf', SET h1='fasdfas', SET meta_description='fas' at line 3

我的代码哪里出错了?

4

3 回答 3

5

您只需要一个SET关键字

 $query="UPDATE search_page
     SET search_page_description='".$search_page_description."',
     title='".$title."',
     h1='".$h1."',
     meta_description='".$metadata."'
     WHERE features_id=".$id;
     $result_update_query=databaseConn :: dbDelta($query);

见参考:http ://dev.mysql.com/doc/refman/5.5/en/update.html

于 2012-04-15T10:46:48.493 回答
1

错误显示第 3 行:

"SET title='".$title."',"

问题是这一行包含一个不期望的“SET”关键字。

 $query="UPDATE search_page
 SET search_page_description='".$search_page_description."',
 title='".$title."',
 h1='".$h1."',
 meta_description='".$metadata."'
 WHERE features_id=".$id;
 $result_update_query=databaseConn :: dbDelta($query);

请参阅MySQL 参考或尝试SQL UPDATE 语句

于 2012-04-15T10:48:39.473 回答
1

试试这些:

>   $query="UPDATE search_page
>      SET search_page_description='".$search_page_description."',
>      title='".$title."',
>      h1='".$h1."',
>      meta_description='".$metadata."'
>      WHERE features_id=".$id;
>      $result_update_query=databaseConn :: dbDelta($query);
于 2012-04-15T10:48:55.710 回答