出于某种原因,我的 php 代码没有将我的变量写入我的 mysql 数据库。
一切正常,直到评论“死在这里”
<?php
$name = ucwords($_POST['name']);
$sex = ucwords($_POST['sex']);
$age = intval($_POST['age']);
$email = $_POST['email'];
//DB ACCESS
$db = mysql_connect("localhost", "root", "root");
mysql_select_db("namedb", $db);
//DB ACCESS
if ($sex != 'M' && $sex != 'F') {
echo "Please go back and enter either M or F for 'Sex' <br />";
echo "<a href='index.html'>Back</a>";
die;
}
if (is_int($age) != yes) {
echo "Please enter a number for your age. <br />";
echo "<a href='index.html'>Back</a>";
die;
}
$query = "INSERT INTO people (age, name, email, sex) VALUES($age, $name, $email, $sex)";
mysql_query($query) or die ("Error Updating DB"); //DIES HERE
echo "Thanks $name, we've added you to our database.";
?>
我的数据库已全部设置完毕,我不知道它为什么不将数据发送到数据库。这是mySQL的图片
谢谢您的帮助。