插入查询不能正常运行php

时间:2015-06-04 17:46:47

标签: php mysql database insert-into isqlquery

 $sql = "INSERT INTO `Visitors`(`Cust_id`, `first_name`, `last_name`,
 `Email_address`, `Phone_no`, `St_Addr`, `city`, `State`, `zip`, `age`,
 `Ethnicity`, `Signup_Date`) VALUES (".'$firstname'.", ".'$lastname'.",
 ".'$email'.", ".'$telephone'.", ".'$Street_Address'.", ".'$City'.",
 ".'$State'.",".'$ZIP'.",".' $age'." , ".'$Ethnicity'.",".'$date'.")";

我正在自动增加

1 个答案:

答案 0 :(得分:2)

列数不匹配。如果是自动增量,则无需指定ID。

同样'$something'将逐字插入 $ something 。您希望使用"插入动态数据。

$sql = "INSERT INTO Visitors
(first_name, last_name, Email_address, Phone_no, St_Addr, city, State, zip, age, Ethnicity, Signup_Date) 
VALUES 
('".$firstname."', '".$lastname."', '".$email."', '".$telephone."', '".$Street_Address."', '".$City."', '".$State."','".$ZIP."','". $age."' , '".$Ethnicity."','".$date."')";