我有这段代码:
mysql_connect('localhost', 'user', 'pass');
mysql_select_db('db');
$$checkusername = mysql_query("SELECT `Username` FROM `users` WHERE `EmailAddress` = '".$email."'");
if(mysql_num_rows($checkusername) == 1)
{
echo "<SCRIPT LANGUAGE='JavaScript'>
window.alert('Sorry, that username is taken. Please go back and try again.')
</SCRIPT>";
}
else
{
echo 'Username Available';
}
实际上,用户名不可用但仍与“用户名可用”相呼应。我也试过这个但仍然是这样的:
mysql_query("SELECT * FROM `users` WHERE `EmailAddress` = '".$email."'");
我不知道我哪里出错了。
答案 0 :(得分:2)
摆脱双美元符号:
$$checkusername = mysql_query("SELECT `Username` FROM `users` WHERE `EmailAddress` = '".$email."'");
应该是
$checkusername = mysql_query("SELECT `Username` FROM `users` WHERE `EmailAddress` = '".$email."'");