您好我是PHP和SQL新手并且遇到了这些错误..
无法将数据附加到我的数据库,也无法找到后退空间......
我正在处理的代码是
提前感谢解决方案...
<?php
$con=mysqli_connect("localhost","root","","nova");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
;
$sql="INSERT INTO signup_form(name,email,contact,subject,message) VALUES('$_POST['name']','$_POST['email']','$_POST['contact']','$_POST['subject']','$_POST['message']')";
if(!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($db));
}
echo "1 record added succesfully";
mysqli_close($con);
?>
NE
答案 0 :(得分:3)
在if
阻止
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
;
^^ //remove this semicolon
您的查询也应该是
$sql="INSERT INTO signup_form(name,email,contact,subject,message) VALUES('".$_POST['name']."','".$_POST['email']."','".$_POST['contact']."','".$_POST['subject']."','".$_POST['message']."')";