This code works on my computer, but when I run it on my web host's server, it doesn't. The output is "Incorrect password or email", even though I'm using the correct password. I thought I had made a mistake with the passwords, but the code won't output $r['email'] or $r['passwordHash'], at the top of the while loop. If I use mysql_result on $sql, I get the data out, so something weird must be happening with mysql_fetch_array. Am I missing something here, or is this more likely a unique problem I should address with my host's support staff?
$query = "SELECT * FROM users WHERE user='$email'";
$sql = mysql_query($query);
while($r = mysql_fetch_array($sql)) {
echo $r['email'];
echo $r['passwordhash'];
if($passwordHash == $r['passwordhash']) {
$_SESSION['user_id'] = $email;
echo "started session";
}
else {
echo "Incorrect password or email";
}
}
$passwordHash
? – BoltClock♦ Feb 11 '11 at 16:53