LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 02-24-2010, 07:09 AM   #1
shifter
Member
 
Registered: May 2006
Distribution: Slackware, DragonFly
Posts: 233

Rep: Reputation: 30
DBD::mysql::st execute failed: Column count doesn't match value count at row 1


I have the following perl/DBI script:
Quote:
#!/usr/bin/perl

use DBI;

my ($db, $user, $pw) = ('dbname', '****', '***********');

my $dbh = DBI->connect("DBI:mysql:$db",$user,$pw) or die "Cannot connect to $db: $DBI::errstr\n" unless (defined $dbh);

my $sth = $dbh->prepare("INSERT INTO clients VALUES('tipo','linguaggio','progetto',1);") or die "$dbh->errstr\n";
my $rc = $sth->execute or die "$dbh->errstr\n";

$dbh->disconnect;
The error message is

[Wed Feb 24 13:03:27 2010] myscript.cgi: DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at myscript.cgi.
[Wed Feb 24 13:03:27 2010] myscript.cgi: DBI::db=HASH(0x8a30c60)->errstr


I am desperated. What is the problem?

Last edited by shifter; 02-24-2010 at 07:12 AM.
 
Old 02-24-2010, 09:46 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,156

Rep: Reputation: 247Reputation: 247Reputation: 247
Hi

It means the SQL you are trying to execute is not correct.

INSERT INTO clients VALUES('tipo','linguaggio','progetto',1)

The table called clients does not have 4 columns. If you want to insert and use default values for the other columns, you need to name each of the columns in the SQL:

INSERT INTO clients (columnName1,columnName2,columnName3,columnName4) VALUES ('tipo','linguaggio','progetto',1)
 
Old 02-24-2010, 08:42 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,310

Rep: Reputation: 2039Reputation: 2039Reputation: 2039Reputation: 2039Reputation: 2039Reputation: 2039Reputation: 2039Reputation: 2039Reputation: 2039Reputation: 2039Reputation: 2039
Never(!) rely on inserting without specifying the col names.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Faillog does not count failed login attempts SecondMet Linux - Security 11 04-19-2010 06:11 AM
Need a way to count sub-directories and get a total count Mo-regard Linux - Newbie 1 08-14-2009 10:10 AM
SWATCH::not able to get the correct match count when i use regular expression vjayraghavan Linux - Newbie 0 03-27-2009 02:16 AM
Should posts in general count on your post count? Joey.Dale General 16 01-27-2004 02:31 AM
ssh failed login count - where is it? mbhenry Linux - Security 1 11-13-2003 12:35 PM


All times are GMT -5. The time now is 10:15 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration