nightcrawler Posted June 27, 2007 Share Posted June 27, 2007 $createaccount_q = "INSERT INTO checkbook_users (id, name, email, password) VALUES (NULL, '$register_name', '$register_email', md5('$register_pw')"; $createaccount = mysql_query($createaccount_q) or die("Couldn't create username. " . mysql_error() ); Always comes out with: "Couldn't create username. 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 '' at line 2" Not sure where my error is. Help Please! Quote Link to comment https://forums.phpfreaks.com/topic/57348-sql-syntax-insert/ Share on other sites More sharing options...
mikew101 Posted June 27, 2007 Share Posted June 27, 2007 try taking the single quotes out of the md5 function. See if that works. Also I tend to use this $query = "INSERT INTO bizdata VALUES ('','$item1','$item2','$etc')"; I dont specify which but fill them all out regardless. So the above example would be for a table with only four fields. Quote Link to comment https://forums.phpfreaks.com/topic/57348-sql-syntax-insert/#findComment-283578 Share on other sites More sharing options...
bubblegum.anarchy Posted June 27, 2007 Share Posted June 27, 2007 Consider this: $result = mysql_query($query = sprintf(" INSERT INTO checkbook_users (id, name, email, password) VALUES (NULL, '%s', '%s', md5('%s'))" , mysql_real_escape_string($register_name) , mysql_real_escape_string($register_email) , mysql_real_escape_string($register_pw))) or trigger_error(mysql_error()."<PRE>".$query."</PRE>", E_USER_ERROR); Quote Link to comment https://forums.phpfreaks.com/topic/57348-sql-syntax-insert/#findComment-283779 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.