php - Error in SQL syntax when I try a query -
i've big (and stupid) problem simple sql insert query (mysqli), i've used format without errors, didn't work..
please me find problem..
//get admin form details $a_user = $_post["a_user"]; $a_pass = $_post["a_pass"]; $a_pin = $_post["a_pin"]; if($a_user == "$admin_username" && $a_pass == "$admin_password" && $a_pin == "$admin_pin"): $keygen = md5(microtime().rand()); $mysqli->query("insert keys (keygen) values ('$keygen')") or die(mysqli_error($mysqli)); $mysqli->close; else: header("location: ?page=admin&error=1"); endif;
here error:
error: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'keys (keygen) values ('85faa7f618e433819d7e5ca57076377c')' @ line 1
keys
mysql reserved word http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
either wrap in backticks or use name it.
insert `keys`
sidenote:
md5 old , considered broken if you're intending on using password purposes.
use crypt_blowfish or php 5.5's password_hash()
function.
php < 5.5 use password_hash() compatibility pack
.
Comments
Post a Comment