我在运行我的程序时在我的 sql 中遇到这样的错误,我该如何解决这个错误?
错误:您的 SQL 语法有错误;查看与您的 MySQL 服务器版本相对应的手册,了解在 's'、's'、's'、's'、's'、's'、's'、's')' 附近使用的正确语法在第 3 行
这是我使用的语法。
<?php
include('config.php');
ERROR_REPORTING("E_ALL");
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>AVAYA</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
</head>
<body>
<div id="page" class="shell">
<div id="mainWrapper">
<div id="top">
<div class="cl"> </div>
<h1><img src="css/images/dtsi-logo.jpg"></h1>
<div class="cl"> </div>
<div>
<?php include_once("template_header.php");?>
</div>
</div>
<?php
$host="localhost"; // Host name
$username="<myusername>"; // Mysql username
$password="<mypassword>"; // Mysql password
$db_name="inventory"; // Database name
$tbl_name="avaya_pabx"; // 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);
$addavaya="INSERT INTO avaya_pabx
(item_no, critical_spare_id, serial_no, comcode, version, circuit_pack, classification, location, availability)
VALUES ('". $_POST['item_no'] . ", '". $_POST['critical_spare_id'] . "', '" . $_POST['serial_no']. "', '". $_POST['comcode'] . "','". $_POST['version'] . "','". $_POST['circuit_pack'] . "','". $_POST['classification'] . "','". $_POST['location'] . "', '". $_POST['availability'] . "')";
$result = mysql_query($addavaya,$con);
if (!$result)
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con);
?>
<br /><a href='avayatable.php'><input type=button class='classname' value='Back'></a>
<?php include_once("template_footer.php");?>
</div>
<br />
</div>
</body>
</html>