I'm writing a simple Perl CGI script to handle some basic queries to my DB for report generation, and I can't get my login to work. First I create a DBI with a dummy user name and password, which can only select and only from the mysql database.
#Part 1 - this returns successfully the hash of the password for the user
my $userSt = $dbh->prepare('SELECT password FROM user WHERE user=?')
or die "Couldn't prepare statement: " . $dbh->errstr;
$userSt->execute('user')
or die "Couldn't execute statement: " . $userSt->errstr;
my @user = $userSt->fetchrow_array();
print $user[0];
#End Part 1
#Part 2 - This part should hash the password given, for comparison with Part 1
#This prepare statement works along - I've tested it.
my $passSt = $dbh->prepare('SELECT PASSWORD(?)')
or die "Couldn't prepare statement: " . $dbh->errstr;
#When I try to execute it, however, it hangs.
#My webbrowser says "waiting for my_ip_address_here"
#and nothing happens
$passSt->execute('password')
or die "Couldn't execute statement: " . $passSt->errstr;
my @pass = $passSt->fetchrow_array();
print $pass[0];
#End Part 2
All of these statements worked exactly as is when typed into MySQL directly, but the second part hangs when I try to do it program-aticlly, and I can't figure out why for the life of me.
Help please?
Brett Bowman
bnbowman@gmail.com