Jump to content

[SOLVED] New User PHP script ( thanks for all your help )


PC Nerd

Recommended Posts

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 ''User_Name', 'Password', 'Email', 'Security_Number', 'F_Name', 'L_Name', 'Age') ' at line 2SQL= INSERT INTO General_Stats ('User_Name', 'Password', 'Email', 'Security_Number', 'F_Name', 'L_Name', 'Age') VALUES ('*****', '*****', '*****', '*****', '*****', '*****')

ive blanked out the actual details, but i checked them, and therye all correctly passed to the page etc.....
Link to comment
Share on other sites

We need to see your actual data. The way it is, there is nothing wrong with your query, so your data must be dojng something.

If we can't see your data for sdecurity reasons your going to be on your own, but my first suggestion would be to escape any quotes.
Link to comment
Share on other sites

ok i redid the new player entry, using the field name as the actual input ( or as close as i could get) and i still got the error.  heres the output, after  my personal message ( ie this is generated by php)

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 ''User_Name', 'Password', 'Email', 'Security_Number', 'F_Name', 'L_Name', 'Age') ' at line 2SQL= INSERT INTO General_Stats ('User_Name', 'Password', 'Email', 'Security_Number', 'F_Name', 'L_Name', 'Age') VALUES ('User_Name', 'Password', 'email@localhost.com', '9069 - 207 - 876', 'FName', 'LName', '30 - 50')
Link to comment
Share on other sites

[code=php:0]
$sql = "INSERT INTO `General_Stats` (`User_Name`,`Password`,`Email`,`Security_Number`,`F_Name`,`L_Name`,`Age`) VALUES ('username','password','email','s_number','fname','lname','age')";
[/code]

NOTE: If the field is an integer you can only insert numerals, meaning no dashes, spaces, etc.. and make sure the field lengths are greater than what you're trying to insert.
Link to comment
Share on other sites

After all that, and I didn't even see it. You dont need (can't have) quotes around your field names.

[code=php:0]
"INSERT INTO General_Stats (User_Name,`Password`,Email,Security_Number,F_Name,L_Name,Age) VALUES ('username','password','email','s_number','fname','lname','age')"
[/code]

Password needs backticks because it is a reserved word.
Link to comment
Share on other sites

ok, thanks age is text BUT the security number ( all of this is the format in the database) is of an integar format, so ill change it and let you know what happens

as using the single quotes instead of double quotes, i dont understand???
Link to comment
Share on other sites

[quote]haha good catch thorpe. He's right, you'd use `` around a field name, not ''.[/quote]

Its a bad habbit to use ` when you dont need to. It was the quotes throwing me off, thinking thery where backticks. If less people used backticks around everything we wouldn't have such problems.
Link to comment
Share on other sites

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 ''User_Name', 'Password', 'Email', 'Security_Number', 'F_Name', 'L_Name', 'Age') ' at line 2SQL= INSERT INTO General_Stats ('User_Name', 'Password', 'Email', 'Security_Number', 'F_Name', 'L_Name', 'Age') VALUES ('User_Name', 'Password', 'email@localhost.com', '3975 - 539 - 388', 'FName', 'LName', '30 - 50')
Link to comment
Share on other sites

[quote]as using the single quotes instead of double quotes, i dont understand???[/quote]

There is no single quotes / double quote issue. The issue is, you cannot put quotes around your field names. However, you must use backticks ( ` ) around reserved words.

See my example.
Link to comment
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.