我不知道如何处理这个错误我的代码
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/>";
}
答案 0 :(得分:2)
if(!result2){
你在那里错过了$。请使用IDE进行编码,这样就可以避免这种错误