dtrpv60860 2012-07-21 04:39
浏览 443
已采纳

错误:字段列表中的未知列

While running the below script it shows the errorError: Unknown column 'email' in 'field list'.

  <?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>';

 }


 ?>

I'm very new to PHP and can't figure out why I'm getting this Error. Shouldn't the $_POST get that value from the form? Thanks for reading.

  • 写回答

3条回答 默认 最新

  • douci1918 2012-07-21 04:42
    关注

    It means your players table does not contain an email column. You will need to add this column to your table for this script to work.

    So the incorrect part in your code is

    $newPlayer = @mysql_query("INSERT INTO players(username, password, registered, callname, email)
                               VALUES('$uname', '$pass', '$date', '$_POST[callname]', '$_POST[email]')") or die("Error: ".mysql_error());
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog