PHP将变量插入mysql数据库问题[关闭]

Below is the code I have. I'm trying to insert the variables into the table orders in the database called coffee. However when I submit the page the variables don't appear in the database.

$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$qty = $_POST['qty'];
$qty_T = $_POST['qty2'];
$option = $_POST['coffee'];
$option_T = $_POST['coffee2'];  
$query = "INSERT INTO orders(Name, Address, City, State, Zip, Quantity, Beans) VALUES ('$name', '$address', '$city', '$state', '$zip', '$qty', '$option')";
mysql_query($query);
mysql_close();

Thanks for your help

Are all your values strings? if zip is just an integer remove the quotes ('').

By the way, you dont need to parse all your POST-paramenters by hand, you can simply call extract($_POST); and all your POST parameters are available as variables.

try this:

extract($_POST);
mysql_query("INSERT INTO orders(Name, Address, City, State, Zip, Quantity, Beans) VALUES ('$name', '$address', '$city', '$state', '$zip', '$qty', '$option')") or die(mysql_error());

mysql_error() should output an error description for failed queries.

try using die(mysql_error()) or try to echo your variables to make sure it had a value in it. Also, try learning PDO much better with CodeIgniter. :)