kennymoens
New Member
Hi all,
I'm running a mySQL database, its correctly set up with phpMyAdmin, but since all my scripts are in Perl I would like to access my database via Perl. I've done this, but I always get a 500 error, so I think there must be an error in my code.
Here is the code:
(Note: some things need to be at the same rule)
Hope you see the error,
thx for the help
I'm running a mySQL database, its correctly set up with phpMyAdmin, but since all my scripts are in Perl I would like to access my database via Perl. I've done this, but I always get a 500 error, so I think there must be an error in my code.
Here is the code:
Code:
# Connection to the Database #
$DSN = "DBI:mysql:database=sabenava_timetable";
$user = "ain't giving to you";
$pw = "ain't giving to you";
$dbh = DBI->connect($DSN,$user,$pw) || die "Connection Failed";
# Executing the command #
my $query="SELECT cat,flightnr,dep,arr,icaodep,
icaoarr,freq,aircraft,deptime,flighttime,arrtime FROM timetable";
my $sth=$dbh->prepare($query);
$sth->execute || die "Could not execute SQL
statement ... maybe invalid?";
# Declare the Variables #
my ($dbcat,$dbflightnr,$dbdep,$dbarr,$dbicaodep,$dbicaoarr,
$dbfreq,$dbaircraft,$dbdeptime,$dbflighttime,$dbarrtime);
print "Content-type: text/html \n\n";
print qq~
<html><head>
<title>Database</title>
</head><body>
~;
# Collect the data #
while ( ($dbcat,$dbflightnr,$dbdep,$dbarr,$dbicaodep,
$dbicaoarr,$dbfreq,$dbaircraft,$dbdeptime,$dbflighttime,
$dbarrtime) = $sth->fetchrow() ) {
print "$dbcat";
}
# Gegevens Afdrukken #
print qq~
</body></html>
~;
$dbh->disconnect;
(Note: some things need to be at the same rule)
Hope you see the error,
thx for the help