運行下面的腳本時,它顯示errorError:'字段列表'中的未知列'email'。錯誤:字段列表中的未知列
<?php
include("connect.php");
if($loggedin == '1')
die("You can't register another account while you're logged in.");
if(isset($_POST['submit']))
{
$uname = trim($_POST['username']);
if($_POST["regkey"]!="171717")
die("Invalid Registration Key. <br> <a href= register.php>Back</a>");
if($_POST["pass"]!=$_POST["pass2"])
die("Passwords do not match. <br> <a href= register.php>Back</a>");
// Make sure all forms were filled out.
if((!isset($_POST['username'])) || (!isset($_POST['pass']))
|| ($uname == '') || ($_POST['pass'] == ''))
die("Please fill out the form completely. <br><br>
<a href=register.php>Continue</a>");
$check = @mysql_query("SELECT id FROM players WHERE username = '$uname'");
$check = @mysql_num_rows($check);
if($check > 0)
die("Sorry, that username has already been taken. Please try again.
<br><br>
<a href=register.php>Continue</a>");
$pass = md5($_POST['pass']);
$date = date("m/d/y");
$newPlayer = @mysql_query("INSERT INTO players (username, password,
registered,callname,email) VALUES ('$uname','$pass','$date','$_POST
[callname]','$_POST[email]')") or die("Error: ".mysql_error());
echo 'You have been registered! You may now <a href=index.php>Log in</a>.';
}
else
{
// A simple example of a form.
echo '
<center>
<form action=register.php method=post>
<p>Registration is currently<b> NOT OPEN.</b><br>
You must have a valid Registration key to register.</p>
<table border="2">
<tr>
<td>Username:</td><td><input type="text" name="username" size="20px"</input>
</td>
</tr>
<tr>
<td>Callname:</td><td><input type="text" name="callname" size="20px"</input>
</td>
</tr>
<tr>
<td>Password:</td><td><input type="password" name="pass" size="20px"</input>
</td>
</tr>
<tr>
<td>Re-type Password:</td><td><input type="password" name="pass2" size="20px"</input>
</td> </tr>
<tr>
<td>Email:</td><td><input type="text" name="email" size="20px"</input></td>
</tr>
<tr><td>Registration Key:</td><td><input type="text" name="regkey" size="20px"></input>
</td> </tr>
</table>
<input type="submit" name="submit" value="Submit"></input>
</form>';
}
?>
我對PHP很陌生,無法弄清楚爲什麼我得到這個錯誤。 $ _POST不應該從表單中獲取該值嗎? 感謝您的閱讀。
謝謝,這是問題。 – Sunden 2012-07-21 04:53:04
很高興聽到。請考慮upvoting我的答案和接受我的答案(通過點擊我的答案旁邊的綠色複選框) – Kris 2012-07-21 05:17:40
在我的情況下,該列確實存在,但我忘記將非整數變量括在引號! ;) – Leo 2016-04-07 15:24:00