sql语法错误检查手册

时间:2014-11-19 01:41:59

标签: php mysql sql mysql-error-1064

我是php编程的新手。我运行代码时总是遇到这个错误

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 'WHERE service_name = ''' at line 7

这是我的代码

<?php
session_start();
include('../conn/openconn.php');
if(isset($_POST['butsend'])) {

$servicename = strtoupper($_POST['txtservicename']);
$serviceurl = $_POST['txtserviceurl'];
$id_div = $_POST['select_div'];
$id_unit = $_POST['select_unit'];
$servicedesc = $_POST['txtservicedesc'];
$id = $_SESSION['service_name'];

$updateuser = "UPDATE service SET 
               service_name = '$servicename',
               service_url = '$serviceurl',              
               id_div = '$id_div',
               id_unit = '$id_unit',
               service_desc = '$servicedesc',
               WHERE service_name = '$id'";
    mysql_query($updateuser) or die (mysql_error());

}

?>

我已经搜索了之前的所有问题,但由于我对编程的了解有限i 找不到解决方案。抱歉我的英语不好..

1 个答案:

答案 0 :(得分:2)

你有一个额外的逗号。删除它。

$updateuser = "UPDATE service SET 
           service_name = '$servicename',
           service_url = '$serviceurl',              
           id_div = '$id_div',
           id_unit = '$id_unit',
           service_desc = '$servicedesc', <-- HERE
           WHERE service_name = '$id'";