Page 1 of 1
PHP/SQL Error Code
Posted: Tue Apr 20, 2004 7:38 am
by ehause
Almost there, BUT....
I have a register.php page connecting to my DB to INSERT form fields into the database. I'm connecting to the DB, but I am getting a PHP error when I submit:
"You could not be registered due to a system error. We apologize for any inconvenience.
Column count doesn't match value count at row 1"
I have checked that all my varibles match the database variables, but I'm not sure where to go from there.
I have no idea what this means and can't find reference to it anywhere. Any ideas, all you pros out there? Thanks in advance, you guys are great!
Eric
Posted: Tue Apr 20, 2004 7:43 am
by malcolmboston
this is on an insert statement it basically means the number of values you are inserting doesnt match the number of fields you have declared
for eg
Code: Select all
// wrong
$insert = "INSERT INTO counter (IP, time, page) VALUES ('$ip_counter', NULL)";
// right
$insert = "INSERT INTO counter (IP, time, page) VALUES ('$ip_counter', NULL, '$page_counter')";
Posted: Tue Apr 20, 2004 9:13 am
by ehause
Malcolm, thanks so much...one last question:
The INSERT query posts to the DB, and all the values are getting posted to the correct fields--except the password is getting inserted as a DATETIME stamp in the PASSWORD field.
Nothing is getting inserted into the CREATED field, which is suppoed to be the DATETIME variable for when the record was created.
Here's the code I have:
// Make the query.
$query = "INSERT INTO members (username, first_name, last_name, email_address, password, created) VALUES ('$u', '$fn', '$ln', '$e', PASSWORD('$p'), NOW() )";
$result = @mysql_query ($query); // Run the query.
if ($result) { // If it ran OK.
What am i doing wrong? Is it in my VALUES order?
Posted: Tue Apr 20, 2004 9:15 am
by ehause
Malcolm:
These are the results from my DB after the record is inserted, showing the row names and the end results:
user_id /username /password /created /last_name /first_name /email_address
5/testagain/2004-04-20 10:08:26/0000-00-00 00:00:00/test/again
Posted: Tue Apr 20, 2004 10:15 am
by Steveo31
You are missing the value of password:
Code: Select all
// Make the query.
$query = "INSERT INTO members (username, first_name, last_name, email_address, password, created) VALUES ('$u', '$fn', '$ln', '$e', PASSWORD('$p'), NOW() )";
$result = @mysql_query ($query); // Run the query.
if ($result) { // If it ran OK.
Your variables are getting messed up somehow... can you post those?
Posted: Tue Apr 20, 2004 10:19 am
by magicrobotmonkey
What is this:
PASSWORD('$p')
a function?
Posted: Tue Apr 20, 2004 10:21 am
by malcolmboston
i think he has mininterpreted the password field
remove (password)
i think he is referring to a mysql field 'type'
Posted: Tue Apr 20, 2004 11:24 am
by ehause
Yup, that's it, thanks guys!