views:

48

answers:

3

Hi every1!

ok so I have this code

`$sql = "INSERT INTO userTable (username, password, gender, city, zip, email) VALUES ('$username', '$password', '$male', '$city', '$email')";
mysql_query($sql) or die ("unable to process query");`

and for some reason it works on my local server but not on the webserver, all the variables are set for sure. it gives me the unable to process query error,

am i doing something obviously wrong? thanks a lot

+6  A: 

You're providing 6 parameters, but only 5 values in your insert statement.

try this

$sql = "INSERT INTO userTable (username, password, gender, city, zip, email) VALUES ('$username', '$password', '$male', '$city', '$zip', '$email')"; mysql_query($sql) or die ("unable to process query");

ScArcher2
god im so stupid thanks man
Pete Herbert Penito
Sometimes it just takes another set of eyes.
ScArcher2
+2  A: 

ScArcher seems to have found the correct answer, but you might also want to know about mysql_error. You can use this to print the error from the database, so next time you can perhaps solve the error yourself.

Mark Byers
cool man good to know i haven't used that before im sure it would be useful
Pete Herbert Penito
Yes this is a great way to see what went wrong with your insert statement.
ScArcher2
+1  A: 

$gender is missing

Yada