I’m trying to create an email validation for user registration.
I am following step by step instructions but i am bogged down in something that should be quite simple.
I am supposed to insert the following into a database using a MySql query:
mysql_query("INSERT INTO users (username, password, email, hash) VALUES(
'". mysql_escape_string($name) ."',
'". mysql_escape_string(md5($password)) ."',
'". mysql_escape_string($email) ."',
'". mysql_escape_string($hash) ."') ") or die(mysql_error());
I am using WAMP server. I went to my database, selected the table, inserted the above after selecting the SQL tab, clicked go and got the response:
“#1064 – 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 ‘mysql_query(“INSERT INTO users (username, password, email, hash)
VALUES( ‘”. m’ at line 1″
I can never seem to insert queries into the phpMyAdmin databases without getting some sort of error. I’m hoping someone can shed some light on this to give me an outside view.
Needless to say, i would be grateful for any input. I am new to this and at my wits end.
As Prash said,
mysql_queryandmysql_escape_stringare php functions beside their names.When pasting into the SQL tab of phpMyAdmin, you should remove the mysql_query() which represents PHP call to MySQL db and convert mysql_escape_string calls to the computed values of variables ($…). It should give you something like:
You need to escape by yourself if there are special chars in values)