Thanks for the catch. I actually had it that way once, but since I couldn't get it to work I dropped it.
#!/usr/bin/perl -w
use strict;
use DBI;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw (:standard);
print "Content-type: text/html\n\n";
my $dbh = DBI->connect(qq{DBI:mysql:database=subscriptions;host=l
+ocalhost,I DON'T HAVE A USERNAME AND PASSWORD OTHER THAN ROOT}, {Rais
+eError => 1} );
my $sth = $dbh->prepare( q{SELECT email FROM contacts WHERE state
+ = ?} );
$sth->execute('OH') or die $sth->errstr;
while (my @result = $sth->fetchrow_array()) {
print "@result\n";
}
# check for problems which may have terminated the fetch early
die $sth->errstr if $sth->err;
$dbh->disconnect;
I've tried many things to connect but to no avail. \s tells me that I'm connected via a UNIX socket. I can only find docs about different ports. Could this be a problem?
Can't call method "prepare" on an undefined value at /usr/local/etc/ht
+tpd/cgi-bin/DBI_mysql_01.pl line 12.
Is there any way to view the path or connection?