View Single Post
  #1 (permalink)  
Old 09-01-2008, 11:56 PM
shiyam198 shiyam198 is offline
Newbie
 
Join Date: Sep 2008
Posts: 11
Credits: 0
Rep Power: 0
shiyam198 is on a distinguished road
Default Column count doesn't match value count at row 1

Dear Guys,

When I am doing an "INSERT" in a PHP file, i am getting an error

"Column count doesn't match value count at row 1"

Normally it comes when the number of column names in a SQL query does not match the number of values we pass in that query.

I made sure it is the case, and i am still getting this error.

My Insert statement
--------------------
PHP Code:
mysql_query("INSERT INTO lk_contact(fname,lname,title,company,worktel1,worktel2,worktel3,workfax,workadd,mobtel1,mobtel2,mobtel3,hometel1,hometel2,hometel3,homeadd,email,webpage,comments,bday,afname,alname,aemail,awrkno,lkgroup) VALUES('$_POST[fname]'),('$_POST[lname]'),('$_POST[title]'),('$_POST[company]'),('$_POST[worktel1]'),('$_POST[worktel2]'),('$_POST[worktel3]'),('$_POST[workfax]'),('$_POST[workadd]'),('$_POST[mobtel1]'),('$_POST[mobtel2]'),('$_POST[mobtel3]'),('$_POST[hometel1]'),('$_POST[hometel2]'),('$_POST[hometel3]'),('$_POST[homeadd]'),('$_POST[email]'),('$_POST[webpage]'),('$_POST[comments]'),('$_POST[bday]'),('$_POST[afname]'),('$_POST[alname]'),('$_POST[aemail]'),('$_POST[awrkno]'),('$_POST[lkgroup]')")
or die(
mysql_error()); 
Just incase, you are intersested - THE TABLE
--------------------------------------------

CREATE TABLE lk_contact(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
fname VARCHAR(30),
lname VARCHAR(30),
title VARCHAR(50),
company VARCHAR(20),
worktel1 VARCHAR(20),
worktel2 VARCHAR(20),
worktel3 VARCHAR(20),
workfax VARCHAR(20),
workadd VARCHAR(20),
mobtel1 VARCHAR(20),
mobtel2 VARCHAR(20),
mobtel3 VARCHAR(20),
hometel1 VARCHAR(20),
hometel2 VARCHAR(20),
hometel3 VARCHAR(20),
homeadd VARCHAR(100),
email VARCHAR(40),
webpage VARCHAR(150),
comments VARCHAR(400),
bday VARCHAR(20),
afname VARCHAR(20),
alname VARCHAR(20),
aemail VARCHAR(20),
awrkno VARCHAR(20),
lkgroup VARCHAR(20));

Please, if you find any thing wrong here, please let me know.. 3 hours of trying different things. No luck.

Thanks for your Time.

Regards.
Shiyam

Last edited by Jaan; 09-02-2008 at 01:10 AM. Reason: Please use code tags when you're posting your codes!
Reply With Quote

Sponsored Links