Jump to content

Recommended Posts

$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

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.