我不断收到此错误:
INSERT 失败:INSERT INTO clientcontact VALUES('Don Jones'、'Walmart'、'need help'、'don@icsbranch.net'、'772-991-0122')列计数与第 1 行的值计数不匹配
我正在尝试从 get_post 函数传递一个 NULL 字段,这是一个自动增量 ID 字段。只是想知道我需要更改什么,以便用户可以填写表格并将信息输入到数据库中,并自动填充查询 ID。
<?php
require_once 'login.php';
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server) die("Unable to connect to MySQL: " . mysql_error());
mysql_select_db($db_database, $db_server)
or die("Unable to select database: " . mysql_error());
{
$name = get_post('name');
$company = get_post('company');
$description = get_post('description');
$email = get_post('email');
$phone = get_post('phone');
$inquiryID = get_post('inquiryID');
$query = "INSERT INTO clientcontact VALUES" .
"('$name', '$company', '$description', '$email', '$phone', NULL)";
if (!mysql_query($query, $db_server))
echo "INSERT failed: $query<br />" .
mysql_error() . "<br /><br />";
}
echo <<<_END
<form action="index.php" method="post"><pre>
Name: <input type="text" name="name" />
Company: <input type="text" name="company" />
Inquiry Details: <input type="text" name="description" />
E-Mail: <input type="text" name="email" />
Phone Number: <input type="text" name="phone" />
<input type="submit" value="ADD RECORD" />
</pre></form>
_END;
mysql_close($db_server);
function get_post($var)
{
return mysql_real_escape_string($_POST[$var]);
}
?>