这是我正在编写的用于更新数据的查询。
$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/