为什么我的PHP代码没有在mysql数据库中输入任何内容


Why isnt my PHP code entering anything into a mysql database

由于某些原因,我无法将POST字符串值或任何与此相关的值发送到我的数据库,所有列都使用长度正确的varchar,我非常确定我是否正确设置了SQL查询语句。我已经查看并找到了与此接近的答案,但它仍然不起作用,我还多次通过PHP验证器运行它,没有语法错误。

以下是我的代码:

Apply.php

<?php
$required = array('name', 'age', 'position', 'email', 'desc');
$name= $_POST["name"];
$age= $_POST["name"];
$email= $_POST["email"];
$position= $_POST["position"];
$desc= $_POST["desc"];
$error = false;
foreach($required as $field) {
  if (empty($_POST[$field])) {
    $error = true;
  }
}
if ($error) {
  echo "You must fill in all fields";
} 
else {
  echo "Application Submitted, You will receive an email with a validation code in 1-2 days </br>Ask the owner in game for faster service";
    mysqli_connect("localhost","root","password","apply");
    mysqli_query("INSERT INTO applications (name, age, email, position, desc) VALUES ('$name', '$age', '$email', '$position', '$desc')");
    mysqli_close();
  }
?>

read_database.php

<?php
$username="root";
$password="password";
$database="apply";
mysql_connect(localhost,$username,$password);
$result = mysqli_query("SELECT * FROM applications") ; 
echo "<table border='1'> 
<tr> 
<th> Name </th> 
<th> Age </th> 
<th> Email Address </th> 
<th> Position </th> 
<th> Reasoning </th> 
</tr>"; 
while($row = mysqli_fetch_array($result)) 
{ 
echo "<tr>"; 
echo "<td>" . $row['Name'] . "</td>"; 
echo "<td>" . $row['age'] . "</td>"; 
echo "<td>" . $row['email'] . "</td>"; 
echo "<td>" . $row['position'] . "</td>"; 
echo "<td>" . $row['desc'] . "</td>"; 
echo "</tr>"; 
} 
echo "</table>";
mysqli_close(); 
?>

阅读mysqli_query的手册http://de2.php.net/manual/en/mysqli.query.php

$link=mysqli_connect("localhost","root","password","apply");
mysqli_query($link,"INSERT INTO applications (name, age, email, position, desc) VALUES ('$name', '$age', '$email', '$position', '$desc')");
mysqli_close();

$mysqli=mysqli_connect("localhost","root","password","apply");
$mysqli->query("INSERT INTO applications (name, age, email, position, desc) VALUES ('$name', '$age', '$email', '$position', '$desc')");
mysqli_close();