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! 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. 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); Link to comment https://forums.phpfreaks.com/topic/57348-sql-syntax-insert/#findComment-283779 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.