Page 1 of 1

php/mysql error

Posted: Mon Jun 09, 2003 3:35 pm
by Cleibe
Ok. Trying to add info to a mysql db and getting a simple error that's driving me crazy

Column count doesn't match value count at row 1

Here's the table
===========================================
$query = "CREATE table newsletterSurvey
(
ID SMALLINT(4) UNSIGNED NOT NULL AUTO_INCREMENT,
learn TEXT,
frequency TEXT,
length TEXT,
format TEXT,
click TEXT,
interest TEXT,
content_area TEXT,
topics TEXT,
degree TEXT,
classYear TEXT,
school TEXT,
age TEXT,
occupation TEXT,
comments TEXT,
date DATE,

PRIMARY KEY(ID)
)" or die (mysql_error());

$results = mysql_db_query($dbName, $query, $connection);

===============================================
Here is the INSERT statement

$query = "INSERT INTO newsletterSurvey VALUES ( '0',
'".$learn."',
'".$frequency."',
'".$length."',
'".$format."',
'".$click."',
'".$interest."',
'".$content_area."',
'".$topics."',
'".$degree."',
'".$classYear."',
'".$school."'
'".$age."',
'".$occupation."',
'".$comments."'
'".$date."')";

$result = mysql_query($query, $connection) or die(mysql_error());


Any idea??
Tks.

quotes man quotes

Posted: Mon Jun 09, 2003 3:55 pm
by phpScott
You are using far to many " a
try this

Code: Select all

$query = "INSERT INTO newsletterSurvey VALUES ( '0',
'$learn',
'$frequency',
'$length',
'$format',
'$click',
'$interest',
'$content_area',
'$topics',
'$degree',
'$classYear',
'$school',
'$age',
'$occupation',
'$comments',
'$date')";
I found what you problem was you missing a couple of comma's at the end of '".$school."' and '".$comments."' which would cause the sql to fail and think that there is less lines than there actually is.

phpScott

Posted: Mon Jun 09, 2003 4:00 pm
by Cleibe
Geee...........you're right.
You don't know for how long I've been looking at this code and couldn't see it.
Thanks a lot.