Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP error - could not execute query... 3

Status
Not open for further replies.

BettyJo50

Technical User
Apr 25, 2002
47
0
0
US
HI All!!

I have a form. When I try to submit the form, I get this error: "Could not execute query: . Column count doesn't match value count at row 1". Could someone possibly tell me what this error means?

Here is some of my code (if it helps):

if ($action=="submit") {
$SQL = "INSERT INTO tblresults VALUES('$fldClass', '$fldq1', '$fldq2', '$fldq3', '$fldq4',
'$fldq5', '$fldComment')";

$result = mysql_db_query($db, "$SQL", $cid) or die ("Could not execute query: $query. " . mysql_error());

Does anyone have any suggestions or advice? If you need more info, just let me know.

THANKS!!! :)

 
That means the number of columns in ur table ar not matching with the values ur trying to insert.
try this instead:

$SQL = "INSERT INTO tblresults(column1,column2,column3,column4,column5,column6,column7) VALUES('$fldClass', '$fldq1', '$fldq2', '$fldq3', '$fldq4',
'$fldq5', '$fldComment')";



--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
The error is explicit. The number of columns of data you are trying to insert into your table is not equal to the number of columns in the table.

If you deliberately mean to insert fewer columns of data than you have columns in the table (you are deliberatly leaving a column or columns blank or default values), then you need to tell MySQL which columns you intend to insert your data into:

"INSERT INTO tblresults (columnname1, columnname2, columnname3, columnname4, columnname5, columnname6, columnname7) VALUES('$fldClass', '$fldq1', '$fldq2', '$fldq3', '$fldq4',
'$fldq5', '$fldComment')";


Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top