Page 1 of 1
SQL Error! Please help
Posted: Fri Nov 08, 2002 1:08 am
by urb
When Im trying to add data into a table I get this error

. Can anyone please help?
"Column count doesn't match value count at row 1"
Thanks,
Matt
please post
Posted: Fri Nov 08, 2002 1:11 am
by phpScott
Please post the sql query you are trying to submit.
As the error says the number of items you are trying to submit doesn't match the number of columns in your table.
They have to match, but that depends on the style of query your are trying to submit.
phpScott
Posted: Fri Nov 08, 2002 1:15 am
by urb
I am trying to add text from 3 fields into a table with 4 fields. The first being set to primary ' id ' and the rest from text fields from forms.
sql code
$sql = "INSERT INTO resources (id, res_name, res_url, res_desc)
VALUES ('$_POST[res_name]', '$_POST[res_url]', '$_POST[res_desc]')";
- Matt
Posted: Fri Nov 08, 2002 1:17 am
by urb
I figured it out. It was that damm ID tag in the sql statement.
Thanks for the help phpScott.
- Matt Urban
try this
Posted: Fri Nov 08, 2002 2:45 am
by phpScott
$sql = "INSERT INTO resources (id, res_name, res_url, res_desc)
VALUES ('$_POST[res_name]', '$_POST[res_url]', '$_POST[res_desc]')";
Is almost correct. If id is discribed as an auto_increment value in your table you still need to put in the spot for it in your insert statement.
This correction should work.
Code: Select all
$sql = "INSERT INTO resources (id, res_name, res_url, res_desc)
VALUES ('','$_POSTїres_name]', '$_POSTїres_url]', '$_POSTїres_desc]')";
phpScott