我有这个简单的代码,我试图在其中有 3 个字段,名字、姓氏和电子邮件,从网站表单标记到 mysql 数据库。当我测试表单并点击“注册”时,出现“发生错误。未添加项目”的错误。我如何调试这个,因为我不确定错误出现在哪一点?
<html>
<head>
<title> Nomad - New User Registration Results</title>
</head>
<body>
<h1>Nomad - New User Registration Results</h1>
<?php
// create short variable names
$First_Name=$_POST['First_Name'];
$Last_Name=$_POST['Last_Name'];
$Email=$_POST['Email'];
if(!$First_Name || !$Last_Name || !$Email) {
echo "You have not entered all the required details.<br />"
."Please go back and try again.";
exit;
}
@ $db=new mysqli('localhost','nomad_steve','steven','nomad_prod');
if (mysqli_connect_errno()) {
echo "Error: Could not connect to database. Get it together Steve!";
exit;
}
$query = "insert into nomad_prod values
(' " .$First_Name.",' " .$Last_Name."',' ".$Email."')";
$result=$db->query($query);
if ($result) {
echo $db->affected_rows." book inserted into database.";
} else {
echo "An Error Has Occured. The item was not added.";
}
$db->close();
?>
</body>
</html>