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, 06: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 06:12 AM.
 
Old 02-24-2010, 08:46 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,449

Rep: Reputation: 446Reputation: 446Reputation: 446Reputation: 446Reputation: 446
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, 07:42 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,344

Rep: Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746Reputation: 2746
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 05:11 AM
Need a way to count sub-directories and get a total count Mo-regard Linux - Newbie 1 08-14-2009 09:10 AM
SWATCH::not able to get the correct match count when i use regular expression vjayraghavan Linux - Newbie 0 03-27-2009 01:16 AM
Should posts in general count on your post count? Joey.Dale General 16 01-27-2004 01:31 AM
ssh failed login count - where is it? mbhenry Linux - Security 1 11-13-2003 11:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:59 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration