I have been working on this for 4 days straight. I'm trying to get MySQL data. I've done it before in PHP but never in Perl. I can "show tables" (so I can access the DB) but nothing else works. Even using use CGI::Carp I just always get a blank page.
use DBI; use CGI::Carp qw(fatalsToBrowser); print "Content-type:text/html\n\n"; $db ="my_webapp2"; $user = "my_user"; $pass = "password"; $host="localhost"; $dbh = DBI->connect("DBI:mysql:$db:$host", $user, $pass); or die "Connecting to MySQL database failed: $DBI::errstr"; $SQLq = ("SELECT username FROM 'sessions' WHERE uid='1'"); $start = $dbh->prepare($SQLq) or die "Preparing MySQL query failed: $DBI::errstr "; $start->execute() or die "The execution of the MySQL query failed: $DBI::errstr"; $result = $start->fetchrow_hashref(); print "Ta-da!: $result->{username}\n"; while ($row = $start->fetchrow_hashref()); $dbh ->disconnect();
In reply to Problems Getting MySQL Data by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |