dqq48152418 2016-06-05 22:06
浏览 43

'where子句'查询中的未知列'email'[重复]

This question already has an answer here:

databaseI'm having trouble getting my registration code working. I keep getting the error:

Unknown column 'email' in 'where clause'

What am i doing wrong? I tried:

$query = "SELECT * FROM register_login WHERE 'email' = '$email'";

and it seemed to work but nothing was uploaded to my database. back in 2014 this code was working perfectly but then i stooped using it for 2 years and now its not working

Here is the server code:

       <?php


            if(isset($_POST['submit'])) {

        // Required field names
        $required = array('email');

        // Loop over field names, make sure each one exists and is not empty
        $error = false;
        foreach($required as $field) {
            if (empty($_POST[$field])) {
            $error = true;
            }
        }

            if ($error) {
                echo 'You forgot to fill in your email';
            } else {
                include("configur.php");
                $email = mysqli_real_escape_string($link, $_POST['email']);

          $query = "SELECT * FROM register_login WHERE email = '$email'";
                $result = mysqli_query($link, $query) or die(mysqli_error($link));

                if (mysqli_num_rows($result) ) {
                    print 'E-mail already exists. Please use a different email';
                }
                else {

          include('config.php');



      // table name 
     $tbl_name="pre_register";

      // Random confirmation code 
       $confirm_code=md5(uniqid(rand())); 




    $fname=$_POST['fname'];
     $lname=$_POST['lname'];

     $fdrink=$_POST['fdrink'];
      $fdrink1= hash("sha512", $fdrink);



       $email=$_POST['email']; 


      $password=$_POST['password']; 
      $encrypt_password= hash("sha512", $password);

     $confirmpassword=$_POST['confirmpassword']; 
     $encrypt_password1=hash("sha512", $confirmpassword);



     // Insert data into database 
     $sql="INSERT INTO $tbl_name(confirm_code, fname, lname, fdrink1, email, encrypt_password, encrypt_password1 )VALUES('$confirm_code', '$fname', '$lname', '$fdrink1',  '$email', '$encrypt_password', '$encrypt_password1')";
      $result=mysql_query($sql);

    // if suceesfully inserted data into database, send confirmation link to email 
     if($result){

    // ---------------- SEND MAIL FORM ----------------


   // send e-mail to ...
   $to=$email;
</div>
  • 写回答

1条回答 默认 最新

  • duandu9260 2016-06-05 22:15
    关注

    Remove the quotes around e-mail:

    $query = "SELECT * FROM register_login WHERE email = '$email'";
    

    For the rest: This code is not secure. Look into PHP-PDO on how to write secure code.

    评论

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口