![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
Hobbyist Programmer
|
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:
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
[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 )...
__________________
|
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
ah that solved my problem. thank you.
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
|
|
#4 | |
|
Hobbyist Programmer
|
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:
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
|
|
|
#5 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Copy your SQL statement and echo it - that'll help you see where you're doing wrong.
|
|
|
|
|
|
#6 | |
|
Hobbyist Programmer
|
i actually did that already, and its weird, i cant see anything wrong with it.
heres the parsed query: Quote:
__________________
Children in the dark cause accidents, and accidents in the dark cause children. http://www.ronincoders.org |
|
|
|
|
|
|
#7 |
|
Programming Guru
![]() ![]() |
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! |
|
|
|
|
|
#8 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#9 |
|
Programming Guru
![]() ![]() |
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! |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|