我有这个查询的问题,它不插入由于某种原因。它有什么问题吗?Mysql插入查询问题
<?php
if (isset($_POST['submit'])) {
$email = $_POST['email'];
$name = $_POST['name'];
$comment = $_POST['comment'];
if($email && $name) {
if($comment) {
$connect = mysql_connect("dragon.kent.ac.uk", "repo", "3tpyril");
mysql_select_db("repo");
$query = mysql_query("INSERT into comments(comment, name,email, newsitemId) VALUES ('$email', '$name','$comment',':newsitemId'=> $_POST[newsitemId])");
echo '<script type="text/javascript">alert("Your blog post has been added");</script>';
} else {
echo '<script type="text/javascript">alert("Please provide some details");</script>';
}
} else {
echo '<script type="text/javascript">alert("All fields required");</script>';
}
}
?>
'':newsitemId'=> $ _POST [newsitemId]'这是错误的。尝试''newsitemId'= $ _ POST [newsitemId]'。此外,mysql_ *函数已被弃用。 –
请减少您的问题,使其涉及_one_语言。不是四个。还学会缩进你的代码。 –
你在这里有一个语法错误:''':newsitemId'=> $ _POST [newsitemId])''。如果你有任何错误,你也可以用''mysql_error()''来检查。无论如何,你应该切换到MySQLi,因为这些功能已被弃用。 – sobyte