0

我不知道如何处理我的代码中出现的这个错误

Notice: Use of undefined constant result2 - assumed 'result2' in C:\xampp\htdocs\how are things\admin panel\register3.php on line 62

第 62 行的代码是

 $result2 = mysql_query("INSERT INTO users (id ,username, user_level, type, first_name, last_name, email, password, phone_number) VALUES('','$username', '2', 'a','$first_name', '$last_name', '$email','$password','$phone_number') ") or die(mysql_error());

这是找到它的代码

if (empty($error)){
     $result = mysql_query("SELECT * FROM users WHERE email='$email' OR username='$username' ") or die(mysql_error());
     $result2 = mysql_query("INSERT INTO users (id ,username, user_level, type, first_name, last_name, email, password, phone_number) VALUES('','$username', '2', 'a','$first_name', '$last_name', '$email','$password','$phone_number') ") or die(mysql_error());
     if(!result2){
        die('Could not insert into the database: '.mysql_error());
     }

    } else{
    $error_message = '<span class="error">';
    foreach($error as $key => $Values){
    $error_message.= "$Values";

    }
    $error_message.="</span><br/><br/>";

    }
4

1 回答 1

2
if(!result2){

你错过了那里的美元。请使用IDE编码,这样可以避免此类错误

于 2013-04-09T15:56:47.130 回答