$value1=$_POST['name'];
$value1=mysqli_real_escape_string($link,$value1);
$value2=$_POST['addr'];
$value2=mysqli_real_escape_string($link,$value2);
$value3=$_POST['phone'];
$value3=mysqli_real_escape_string($link,$value3);
$value4=$_POST['type'];
$value4=mysqli_real_escape_string($link,$value4);
$value5=$_POST['qty'];
$value5=mysqli_real_escape_string($link,$value5);
$sql1= "INSERT INTO guests ('Name','Address','phone','pizza_type','quantity') VALUES ('$value1','$value2','$value3','$value4','$value5')";
$records1=mysqli_query($link,$sql1) or trigger_error(mysqli_error($link). " in ".$sql1);
$sql2="SELECT * FROM 'guests'";
$records2=mysqli_query($link,$sql2) or trigger_error(mysqli_error($link)." in ".$sql2);
答案 0 :(得分:0)
1)更改
$sql1= "INSERT INTO guests ('Name','Address','phone','pizza_type','quantity') VALUES ('$value1','$value2','$value3','$value4','$value5')";
要
$sql1= "INSERT INTO guests (`Name`,`Address`,`phone`,`pizza_type`,`quantity`) VALUES ('$value1','$value2','$value3','$value4','$value5')";
2)更改
$sql2="SELECT * FROM 'guests'";
要
$sql2="SELECT * FROM `guests`";
Single quotes
不允许包含列名或表名。相反,请使用backtick
。
查找反引号
答案 1 :(得分:0)
对表名使用反引号(`)。
$sql1= "INSERT INTO `guests`....";
...
$sql2="SELECT * FROM `guests`";
答案 2 :(得分:0)
1. $sql1= "INSERT INTO guests (Name, Address, phone, pizza_type, quantity) VALUES ('$value1','$value2','$value3','$value4','$value5')";
2. $sql2="SELECT * FROM guests";