我收到以下错误: 解析错误:语法错误,第31行/usr/www/whatsup4/Tool/run.php中的意外文件结尾
这是我的代码:
define('DB_NAME', 'whatsup4_tool');
define('DB_USER', 'whatsup4');
define('DB_PASSWORD', 'xxxxx');
define('DB_HOST', 'localhost');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if (!$db_selected) {
die('Can\'t use ' . DB_NAME . ': ' . mysql_error());
}
$value1 = $_POST['64id'];
$value2 = $_POST['b64id'];
$value3 = $_POST['info'];
$value4 = $_POST['ev'];
$sql = "INSERT INTO whatsup4_tool (64id, b64id, info, ev) VALUES ('$value', '$value2',
'$value3', '$value4');
mysql_query($sql);
mysql_close();
?>
我还需要在最后添加其他内容吗?我以前从未用SQL编码。如果相关,这里是HTML代码:
<form action="run.php" method="post"/>
<p>User's 64 ID: <input type="text" name="64id"/></br>
<p>Your 64 ID: <input type="text" name="b64id"/></br>
<p>Infringement: <input type="text" name="info"/></br>
<p>Evidence: <input type="text" name="ev"/></br>
<input type="submit" value="Submit"/>
</form>
答案 0 :(得分:2)
您在查询结束时错过了"
(关闭双引号)
尝试替换
$sql = "INSERT INTO whatsup4_tool (64id, b64id, info, ev) VALUES ('$value', '$value2',
'$value3', '$value4');
到
$sql = "INSERT INTO whatsup4_tool (64id, b64id, info, ev) VALUES ('$value', '$value2', '$value3', '$value4')";
答案 1 :(得分:1)
您收到错误,因为您错过了双引号:
此代码:
$sql = "INSERT INTO whatsup4_tool (64id, b64id, info, ev) VALUES ('$value', '$value2',
'$value3', '$value4')<double-quote-missing>;
应该是:
$sql = "INSERT INTO whatsup4_tool (64id, b64id, info, ev) VALUES ('$value', '$value2',
'$value3', '$value4')";