php - 在php中更新数据库

标签 php mysql

这是我正在编写的用于更新数据的查询。

 $sql=makeSQL($myVals,$fieldsu,
        "update users set", 
        "where id='".mysql_real_escape_string($_POST["PID"])."'");

但是我收到错误

update users set'Amol','Kulkarni','amol@e10.in','amol','9870004268')Error Save [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 ''Amol','Kulkarni','amol@e10.in','amol','9870004268')' at line 1]

建议我这样做......

最佳答案

您必须指定要设置的列,如下所示

update your_table set col1 = 'a', col2 = 'b' where id = 3

您的代码容易受到 SQL 注入(inject)攻击。请先解决该问题。请参阅best way to prevent SQL injection in PHP

关于php - 在php中更新数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13174169/

相关文章:

php - 在Woocommerce中更改Paypal产品项名称

PHP 简单 XML : Handling Unknown Namespaces in SOAP Requests

php - 如何在 html 页面中显示数据库的值?

php - 恰好 10 个字符的 perl 正则表达式

c# - 从另一个表插入值后触发

mysql - 如果子查询返回空值,如何删除一行?

php - 危险的 php 函数

mysql - 如何检查MySQL的优化工作与否?

java - 使用有效查询字符串的PreparedStatement MySQLSyntaxErrorException

php - 选择第 n 页而不是第 n 页