in reply to Display row with no value in column
First of all, you need to load DBI.pm into your script for any of the database functions you are using to work. Then you have to connect to the database.
I've got 2 words for you:
perldoc DBI :-)
You really need to read the docs for that(that command will get them for you), and perhaps even give yourself a rundown on packages and modules. Rework your code after that then come back and ask.
For now a little demonstration of DBI.pm:
You also need to make sure that DBI.pm is installed on your system. Type:#!/usr/bin/perl use DBI; use strict; # connect to the database, using mysql in example my $dbh = DBI->connect("DBI:mysql:dbname:hostname", "user", "pass") or + die "Couldn't Connect: $DBI::errstr"; # prepare statement handle $sth = $dbh->prepare("SELECT * FROM table WHERE field = ?); # ? is a placeholder that can be filled when execute is called $sth->execute($val_of_field) or die "Error: $DBI::errstr"; # $DBI::errstr stores the error string returned by the DB while (@vals = $sth->fetchrow->array()) { # do stuff # do more stuff } $sth->finish(); #close statement handle $dbh->disconnect(); #disconnect
Really you should just start out by reading some docs and getting a better understanding of how to use DBI.pmCan't locate Blah.pm in @INC (@INC contains: /home/harvester/lib/perl5 +/i386-linux /home/harvester/lib/perl5 /usr/lib/perl5/5.00503/i386-lin +ux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_perl/5.005/i386-linux / +usr/lib/perl5/site_perl/5.005 .) at -e line 1. BEGIN failed--compilation aborted at -e line 1.
Amel - f.k.a. - kel
|
|---|