我仍然遇到错误。
错误:您的 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);
?>