我有这个脚本:
include ('connect.php');
$data = mysql_query("SELECT * FROM projects WHERE id='2'") ;
$da = mysql_fetch_array($data);
if(isset($_POST['submit'])){
$name = $_POST['project_name'];
$date = $_POST['date'];
$amount = $_POST['amount'];
$curr = $_POST['curr'];
$spec = $_POST['spec'];
$sql = "UPDATE projects
SET (name='$name', date='$date', amount='$amount', currency='$curr', specifications='$spec')
WHERE id=2";
$res = mysql_query($sql);
if($res)
{
echo "Upadate Successfull!";
}
else
{
echo "Sorry!";
echo mysql_error($connect)."<br />";
echo error_reporting(E_ALL)."<br />";
echo ini_set('desplay_errors','1');
}
注意:connect.php文件工作正常,因为我之前在其他脚本上使用过它,但是在同一台服务器上。
每次我尝试提交表单时:
Sorry!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 '(name='sdadas', date='08/21/2013', amount='2444', currency='dollars', specificat' at line 2
32767
可能是什么问题?
答案 0 :(得分:2)
尝试不带括号的相同查询。
答案 1 :(得分:1)
UPDATE .. SET
语法不使用括号:
UPDATE projects
SET name='myproject', date='08/21/2013', amount='2444', currency='dollars', specifications='None'
WHERE id=2
答案 2 :(得分:0)
当你似乎输入一个int时,问题是你有大约数量的引号。