Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 15th, 2005, 11:49 PM   #1
Intimidat0r
Hobbyist Programmer
 
Intimidat0r's Avatar
 
Join Date: May 2005
Location: Don't know, but the padded walls are a nice touch.
Posts: 126
Rep Power: 0 Intimidat0r is an unknown quantity at this point
Send a message via ICQ to Intimidat0r Send a message via AIM to Intimidat0r Send a message via MSN to Intimidat0r Send a message via Yahoo to Intimidat0r
Sql Insert

ok i feel retarted right now. i have this sql query:

$query_result = mysql_query("INSERT INTO users ('username', 'password', 'email', 'security_question', 'answer', 'zipcode', 'state', 'country', 'city', 'telephone', 'aim', 'msn') VALUES ('".$username."','".$password."','".$_POST['email']."','".$security_question."','".$answer."','".$zipcode."','".$state."','".$country."','".$city."','".$telephone."','".$aim."','".$msn."',", $conn) or die(mysql_error());

and its dying with this:

Quote:
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 ''username', 'password', 'email', 'security_question', 'answer',
and yes all the variables are declared, im properly connected, etc., etc.
__________________
Children in the dark cause accidents, and accidents in the dark cause children.

http://www.ronincoders.org
Intimidat0r is offline   Reply With Quote
Old Nov 16th, 2005, 6:29 AM   #2
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
[php]$query_result = mysql_query("INSERT INTO users ('username', 'password', 'email', 'security_question', 'answer', 'zipcode', 'state', 'country', 'city', 'telephone', 'aim', 'msn') VALUES ('".$username."','".$password."','".$_POST['email']."','".$security_question."','".$answer."','".$zipcode."','".$state."','".$country."','".$city."','".$telephone."','".$aim."','".$msn."')", $conn) or die(mysql_error());[/php]

On the end of your SQL statement you were still using "','" . $variable . "'," and at some point you have to end it with a )...
__________________

tempest is offline   Reply With Quote
Old Nov 16th, 2005, 3:20 PM   #3
Intimidat0r
Hobbyist Programmer
 
Intimidat0r's Avatar
 
Join Date: May 2005
Location: Don't know, but the padded walls are a nice touch.
Posts: 126
Rep Power: 0 Intimidat0r is an unknown quantity at this point
Send a message via ICQ to Intimidat0r Send a message via AIM to Intimidat0r Send a message via MSN to Intimidat0r Send a message via Yahoo to Intimidat0r
ah that solved my problem. thank you.
__________________
Children in the dark cause accidents, and accidents in the dark cause children.

http://www.ronincoders.org
Intimidat0r is offline   Reply With Quote
Old Nov 16th, 2005, 9:04 PM   #4
Intimidat0r
Hobbyist Programmer
 
Intimidat0r's Avatar
 
Join Date: May 2005
Location: Don't know, but the padded walls are a nice touch.
Posts: 126
Rep Power: 0 Intimidat0r is an unknown quantity at this point
Send a message via ICQ to Intimidat0r Send a message via AIM to Intimidat0r Send a message via MSN to Intimidat0r Send a message via Yahoo to Intimidat0r
now its giving me another one:

$query_result = mysql_query("INSERT INTO users (username, password, email, security_question, answer, zipcode, state, country, city, telephone, aim, msn, character, league) VALUES ('".$username."','".$password."','".$_POST['email']."','".$security_question."','".$answer."','".$zipcode."','".$state."','".$country."','".$city."','".$telephone."','".$aim."','".$msn."','".$character."','".$league."')", $conn) or die(mysql_error());

Quote:
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 'character, league) VALUES ('intimidat0r','b1076926499e320b667dd
any help would be appreciated. thanks.
__________________
Children in the dark cause accidents, and accidents in the dark cause children.

http://www.ronincoders.org
Intimidat0r is offline   Reply With Quote
Old Nov 17th, 2005, 11:23 AM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Copy your SQL statement and echo it - that'll help you see where you're doing wrong.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 17th, 2005, 7:19 PM   #6
Intimidat0r
Hobbyist Programmer
 
Intimidat0r's Avatar
 
Join Date: May 2005
Location: Don't know, but the padded walls are a nice touch.
Posts: 126
Rep Power: 0 Intimidat0r is an unknown quantity at this point
Send a message via ICQ to Intimidat0r Send a message via AIM to Intimidat0r Send a message via MSN to Intimidat0r Send a message via Yahoo to Intimidat0r
i actually did that already, and its weird, i cant see anything wrong with it.

heres the parsed query:

Quote:
INSERT INTO users (username, password, email, security_question, answer, character, league) VALUES ('intimidat0r','b1076926499e320b667dd1a3c8df1c99','intimidat0r.bb@gmail.com','What is your favorite pet\'s name?','Toby','Bully','Infamous')
__________________
Children in the dark cause accidents, and accidents in the dark cause children.

http://www.ronincoders.org
Intimidat0r is offline   Reply With Quote
Old Nov 18th, 2005, 9:14 AM   #7
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
a stab in the dark: try a ; at the end of your statment. You shouldn't need it, but it won't hurt it ether.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Nov 18th, 2005, 10:02 AM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
The two latest quotes representing your problem are different. What gives? If you're whittling back to exclude possibly mislabeled names, it isn't a bad idea. Just keep whittling. We can't know what the real column names (or aliases) or variable names are. The way I generally do it is construct a sql string, then pass that to the query. If it fails, and I can't see why, I can put an echo of the string. When it finally works, I can just comment it out.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 18th, 2005, 10:45 AM   #9
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
Another thing to check is the data types that you have for your columns. If you have column that is Char(10) and you try and put 20 characters into it, it will fail.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:46 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC