我正在尝试插入到mysql表中,并且我收到了一个意外结束文件的解析错误。我正在使用带有基本表单的html文件供用户输入数据。我有一个php文件,当用户输入数据时,由于解析错误而失败。我是php的初学者所以我很感激任何建议。
这是我的HTML代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Grooming Appointment</title>
</head>
<body>
<form action="submit.php" method="post">
<p>
<label for="FirstName">First Name:</label>
<input type="text" name="Firstname" id="FirstName">
</p>
<p>
<label for="LastName">Last Name:</label>
<input type="text" name="LastName" id="LastName">
</p>
<p>
<label for="Address">Address:</label>
<input type="text" name="Address" id="Address">
</p>
<p>
<label for="City">City:</label>
<input type="City" name="City" id="City">
</p>
<p>
<label for="State">State:</label>
<input type="State" name="State" id="State">
</p>
<p>
<label for="Zip">Zip:</label>
<input type="Zip" name="Zip" id="Zip">
</p>
<p>
<label for="PhoneNumber">Phone Number:</label>
<input type="PhoneNumber" name="PhoneNumber" id="PhoneNumber">
</p>
<p>
<label for="Email">Email:</label>
<input type="Email" name="Email" id="Email">
</p>
<p>
<label for="PetType">Pet Type:</label>
<input type="PetType" name="PetType" id="PetType">
</p>
<p>
<label for="Breed">Breed:</label>
<input type="Breed" name="Breed" id="Breed">
</p>
<p>
<label for="PetName">PetName:</label>
<input type="PetName" name="PetName" id="PetName">
</p>
<p>
<label for="NeuteredOrSpayed">Neutered or Spayed:</label>
<input type="NeuteredOrSpayed" name="NeuteredOrSpayed" id="NeuteredOrSpayed">
</p>
<p>
<label for="PetBirthday">Pet Birthday:</label>
<input type="PetBirthday" name="PetBirthday" id="PetBirthday">
</p>
<input type="submit" value="Submit">
</form>
</body>
</html>
这是我的php:
<?php
$host="";
$port=3306;
$socket="";
$user="";
$password="";
$dbname="";
$con = new mysqli($host, $user, $password, $dbname, $port, $socket)
or die ('Could not connect to the database server' . mysqli_connect_error());
if( $_POST )
{
$con = mysql_connect("localhost","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("pet_shop3", $con);
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
$Address = $_POST['Address'];
$City = $_POST['City'];
$State = $_POST['State'];
$Zip = $_POST['Zip'];
$PhoneNumber = $_POST['PhoneNumber'];
$Email = $_POST['Email'];
$PetType = $_POST['PetType'];
$Breed = $_POST['Breed'];
$PetName = $_POST['PetName'];
$NeuteredOrSpayed = $_POST['NeuteredOrSpayed'];
$PetBirthday = $_POST['PetBirthday'];
$query = "
INSERT INTO `grooming` (`FirstName`, `LastName`, `Address`,
`City`, `State`, `Zip`, `PhoneNumber`, `Email`, `PetType`, `Breed`, `PetName`, `NeuteredOrSpayed`, `PetBirthday`) VALUES (NULL, '$users_FirstName','$users_LastName', '$users_Address', '$users_City', '$users_Address', '$users_State', '$users_Zip', '$users_PhoneNumber', '$users_Email', '$users_PetType', '$users_PetName', '$users_Breed', '$users_PetName', '$users_NeuteredOrSpayed', '$users_PetBirthday',);";
mysql_query($query);
echo "<h2>Thank you, we will contact you shortly!</h2>";
mysql_close($con);
?>
答案 0 :(得分:0)
您输入的插入次数少于实际数据
FirstName
,LastName
,Address
,
City
,State
,Zip
,PhoneNumber
,Email
,PetType
,Breed
,PetName
,{{ 1}},NeuteredOrSpayed
13输入
尽管
PetBirthday
16 MYSQL中有效语法错误的值。