INSERT INTO php mysql statement is not working due to incorrect syntax.
Trying to figure out why the following code produces this error.
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near ''username' ,
'password' ) VALUES ('Pangamma', '39ef1e6d2fb0743000e5956362b6dc55'' at
line 1
The password, email, and user are all correct. So are the database
settings. I've been whacking my head on a wall for 3 hours now. Probably
something stupidly simple. What am I doing wrong?
/** returns a reason if it fails **/
function addUser($user,$password,$email){
global $db_database;global $tb_logins;global $tb_info; global
$tb_licenses;
$licensekey = md5($user.$password.$email);
$hash = md5($user.'please'.$password.'the salt');
if (mysql_num_rows(mysql_query("SELECT * FROM ".$tb_logins."
WHERE username='$user'")) > 0){
return 'error : username already in use.';
}
mysql_query("INSERT INTO `$db_database`.`$tb_logins` (
'username' , 'password' ) VALUES ('$user', '$hash')") or
die(mysql_error());
mysql_query("INSERT INTO $tb_info
(`username`,`email`,`licensekey`,`limit`) VALUES
('".$user."','".$email."','".$licensekey."','0')") or
die(mysql_error());
return 'success!';
}
No comments:
Post a Comment