Reputation: 9054
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';
}
Upvotes: 0
Views: 53
Reputation: 360572
key
is a reserved word, you'll have to escape it:
INSERT INTO $new_tbl_name (Email, `Key`) VALUES
^ ^
As a general suggestion, simply saying "error" is utterly useless for debugging purposes. Have mysql TELL you what's wrong:
if (!$result) {
die(mysql_error());
}
so you have a clue as to what's wrong, instead of just poking around in the dark.
Upvotes: 3