0

我有这个脚本:

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

可能是什么问题呢?

4

3 回答 3

2

尝试不带括号的相同查询。

于 2013-08-07T19:24:35.010 回答
1

UPDATE .. SET语法不使用括号:

UPDATE projects 
   SET name='myproject', date='08/21/2013', amount='2444', currency='dollars', specifications='None'
   WHERE id=2
于 2013-08-07T19:25:40.683 回答
0

问题是否可能是当您似乎正在输入一个 int 时,您在金额周围加上引号。

于 2013-08-07T19:22:46.327 回答