-3

我仍然遇到错误。

错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 2 行的“comcode, version, classification, location, availability, date, client) VALUES 附近使用正确的语法

  <?php
    $host="localhost"; // Host name 
    $username="user1"; // Mysql username 
    $password="test123"; // Mysql password 
    $db_name="inventory"; // Database name 
    $tbl_name="cisco"; // Table name

    mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");


    $con = mysql_connect("localhost","root","");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    mysql_select_db("inventory", $con);


    $addcisco="INSERT INTO cisco
    (critical_spare_id, serial_no, ,comcode, version, classification, location, availability, date, client)
    VALUES ('". $_POST['critical_spare_id'] . "', '" . $_POST['serial_no']. "', '". $_POST['comcode'] . "','". $_POST['version'] . "','". $_POST['classification'] . "','". $_POST['location'] . "', '". $_POST['availability'] . "', '". $_POST['date'] . "', '". $_POST['client'] . "')";


    mysql_query($addcisco,$con);

    if (!mysql_query($addcisco,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "1 record added";

    mysql_close($con);

    ?>
4

1 回答 1

2

您的插入语句中有一个空列名:

(critical_spare_id, serial_no, ,comcode, version,

                              ^
于 2012-04-30T03:35:10.397 回答