Does anybody know why the following PHP code keeps throwing errors: I have been unable to log any proper error other than the if statement $result not going through and giving me the Echo 'Error' statement. Is there something wrong with my insertion?
$new_tbl_name = 'Password_Reset';
$sql = "INSERT INTO $new_tbl_name (Email, Key) VALUES ('$email','$resetHash')";
$result = mysql_query($sql);
if ($result) {
}
else {
echo 'Error';
}
keyis a reserved word, you’ll have to escape it:As a general suggestion, simply saying “error” is utterly useless for debugging purposes. Have mysql TELL you what’s wrong:
so you have a clue as to what’s wrong, instead of just poking around in the dark.