if($_GET['action'] == "add"){
if($_SERVER['REQUEST_METHOD'] == "POST"){
if(empty($_POST['bugtitle']) || empty($_POST['bugdetails'])){
echo 'One of the fields was empty! Go back and try again.<br/>';
}
else
{
$query = "INSERT INTO bra
(
bugtitle,
bugdetails,
status,
ip,
)
VALUES
(
'". mysql_real_escape_string($_POST['bugtitle']) ."',
'". mysql_real_escape_string($_POST['bugdetails']) ."',
'0',
'". $_SERVER['REMOTE_ADDR'] ."'
)";
$mysqlquery = mysql_query($query);
if($mysqlquery){
echo 'Bug reported.<br/>';
}
else
{
echo 'Mysql query failed! Please contact the webmaster!<br/>'.mysql_error().'<br/>'.$query;
}
}
}
else
{
?>
<form action="bra.php?action=add" method="post">
Bug title: <input type="text" name="bugtitle"/><br/>
Details:<br/>
<textarea cols="50" rows="5" name="bugdetails"></textarea><br/>
By pressing 'submit' you understand that you will not spam and your ip adress will be logged.<br/>
<input type="submit" value="submit"/>
</form>
<?php
}
}
这就是它返回的内容:
Mysql查询失败!请联系网站管理员! 您的SQL语法有错误;查看与您的MySQL服务器版本相对应的手册,以便在')附近使用正确的语法('有一个错误','及其调用'在第7行 INSERT INTO bra(bugtitle,bugdetails,status,ip,)VALUES('有一个bug','它叫做maja','0','127.0.0.1')
此查询有什么问题?!?
答案 0 :(得分:1)
删除ip
后的逗号。
INSERT INTO bra
(
bugtitle,
bugdetails,
status,
ip
)
答案 1 :(得分:1)
INSERT INTO bra
(
bugtitle,
bugdetails,
status,
ip,
)
ip是逗号之后,你应该删除它
答案 2 :(得分:0)
你在values
之前再放了一个COMMA(,)。
检查一下:
$query = "INSERT INTO bra
(
bugtitle,
bugdetails,
status,
ip
)
VALUES
(
'". mysql_real_escape_string($_POST['bugtitle']) ."',
'". mysql_real_escape_string($_POST['bugdetails']) ."',
'0',
'". $_SERVER['REMOTE_ADDR'] ."'
)";