php - 更新查询 MySQL PHP

标签 php mysql

我正在尝试使用以下查询更新我的表...

 $query = mysql_query("UPDATE `outgoings` (id, user_id, bill, bill_name, bill_description, bill_colour ) VALUES ('$id', '$uid', '$bill', '$billname', '$billdescription', '$billcolour') WHERE id = '$id'") or die(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 '(id, user_id, bill, bill_name, bill_description, bill_colour ) VALUES ('', '8464' at line 1

我试过删除我的变量周围的 ' 并在谷歌上搜索替代方法,但似乎无法弄清楚我做错了什么?

最佳答案

将此语法用于 update 语句:

UPDATE `outgoings` set id = '$id', user_id = '$uid' ... where ...

我猜你把它和 insert 语句混在一起了。

关于php - 更新查询 MySQL PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10147951/

相关文章:

php - 循环数组,如果键值存在,则向结构化数组添加 1

PHP 非假空合并运算符

mysql - 根据列值的增量选择多行

mysql - 在同一个 mysql 表中的 INSERT INTO 之后获取最后插入的 id(s) 的列表

php - 已弃用 : Function split() is deprecated. 如何修复此语句?

php - MySQL 查询不检查条件

java - 未知数据库和连接关闭后不允许任何操作

php - searchBar.resignFirstResponder() 导致 nil 值

php - 我正在经历一个 php 后台进程问题

mysql - 内部连接效果不佳