我有 html 表单
<form name="booksInput" action="theGamer.php" method="post">
Book Name: <input type="text" name="books">
<input type="submit" value="Submit" name="subBooks">
</form>
用于抓取然后插入值的 php 代码如下
$con=mysql_connect("localhost","root","","library");
$book=$_POST['books'];
$sql="INSERT INTO books (bID, book) VALUES ('','$_POST['books']')";
if (!mysql_query($con,$sql))
{
die('Error: ' . mysql_error($con));
}
echo "1 record added";
这是mysql表
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| bID | int(11) | NO | PRI | NULL | auto_increment |
| book | varchar(30) | NO | | NULL | |
+-------+-------------+------+-----+---------+----------------+
但它给了我错误解析错误,期待T_STRING' or
第 8 行 C:\wamp\www\library\theGamer.php 中的 T_VARIABLE' 或 `T_NUM_STRING'