MySQL and Perl DBI
I am trying to use the Perl DBI module to access a MySQL database used for the website for TPIT Club at school. I have never used MySQL before and I didn't even know if could be used with Perl until recently. The server I am using supports perl MySQL access but I am getting a weird bug in my scripts which I cannot test on my computer since I haven't set up MySQL access from perl on my own computer. The code that has the error is:
The error is that after I instantiate the $dbh variable anything printed after that is not actually printed. This means that test2, which should be printed as output, is not. If I remove the $dbh line it works fine. The three variables used ($dsn, $user, $pass) are defined correctly.
Calling all perl developers: What is wrong with my code?
print "test";
$dbh = DBI->connect($dsn, $user, $pass)
or die "Can't connect to DBI";
print "test2";
$user = $dbh->prepare('SELECT * FROM `TPIT_users` WHERE username = "$username"')
or die "Couldn't prepare statement: " . $dbh->errstr;
@user = $user->fetchrow_array();
if($password eq $user[2])
{
return "true";
}
$dbh->disconnect();
The error is that after I instantiate the $dbh variable anything printed after that is not actually printed. This means that test2, which should be printed as output, is not. If I remove the $dbh line it works fine. The three variables used ($dsn, $user, $pass) are defined correctly.
Calling all perl developers: What is wrong with my code?


0 Comments:
Post a Comment
<< Home