Ok, here's a code snippet from my perl program phonebook.pl:
sub show_entries {
my ($dbh, $sth, @row);
$dbh = DBI->connect("DBI:mysql:database=$serverDb;host=$serverName;port=$serverPort",$serverUser,$serverPass) ;
$sth = $dbh->prepare("SELECT Name FROM $serverTable");
$sth->execute;
When I
http://localhost/cgi-bin/phonebook.pl I get the following error:
Software error:
Can't call method "prepare" on an undefined value at /home/httpd/cgi-bin/phonebook.pl line 22.
Line 22 is the line that begins "$sth=$dbh->prepare...".
I've declared:
my $serverName= "localhost";
my $serverPort = "3306";
my $serverUser = "listing";
my $serverPass = "password";
my $serverDb = "phonebook";
my $serverTable = "listing";
Within the "phonebook" database I have a table correctly setup called "listing" with a column called "Name" with some values in it.
I've also done:
insert into host(Host,Db)values('localhost','phonebook');
insert into user(Host,User,Password) values ('localhost' ,'listing','PASSWORD('password'));
Any idea what's going on?