{
$con=mysqli_connect("localhost","root","password","table");
// Check connection
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="INSERT INTO center (Name, Age, Address, Phone)
VALUES
('$_POST[Name]','$_POST[Age]''$_POST[Address]','$_POST[Phone]')";
if (!mysqli_query($con,$sql)){
die('Error: ' . mysqli_error($con));
}
else echo "1 record added";
mysqli_close($con);
}
答案 0 :(得分:1)
看起来像一个糟糕的INSERT查询
$sql="INSERT INTO center (Name, Age, Address, Phone)
VALUES
('$_POST[Name]','$_POST[Age]''$_POST[Address]','$_POST[Phone]')";
以强>
$name=$_POST[Name];
$age=$_POST[Age];
$address=$_POST[Address];
$phone=$_POST[Phone];
$sql="INSERT INTO center (Name, Age, Address, Phone)
VALUES
('$name','$age','$address','$phone')";
答案 1 :(得分:1)
你错过了'$ _POST [Age]'和'$ _POST [Address]'之间的逗号,所以你只提供三个值来插入四列。