RexJacobus
Programmer
Apache is running. (I can run HelloWorld.cgi)
MySQL is running and password is correct. (I can query from the cmd line)
Can someone give me a clue why the following code doesn't work?
________________________________
#!/perl/bin/perl <i>(correct path in dev)</i>
print "Content-type: text/html\n\n";
print "**********Connect Test\n";
use DBI;
# Connecting to the database
# Replace DATABASENAME with the name of the database,
# HOSTNAME with the hostname/ip address of the MySQL server.
$drh = DBI->install_driver("mysql");
$dsn = "DBI:mysql:database=homer;host=mysql.secureserver.net";
$dbh = DBI->connect($dsn,"root","simpson");
# Select the data and display to the browser
my $sth = $dbh->prepare("SELECT * FROM players");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref()) {
print "Found a row: id = $ref->{'id'}, name = $ref->{'name'}n";
}
$sth->finish();
# Disconnect from the database.
$dbh->disconnect();
_______________________________
When I run this from the cmd line I get
Content-type: text-html
*******************Connect Test
DBI connect('database=homer;host=mysql.secureserver.net','root',... failed:
Can't connect to MySQL server on 'mysql.secureserver.net' (10060) at connecttest.cgi line 12.
Thanks,
Jim
MySQL is running and password is correct. (I can query from the cmd line)
Can someone give me a clue why the following code doesn't work?
________________________________
#!/perl/bin/perl <i>(correct path in dev)</i>
print "Content-type: text/html\n\n";
print "**********Connect Test\n";
use DBI;
# Connecting to the database
# Replace DATABASENAME with the name of the database,
# HOSTNAME with the hostname/ip address of the MySQL server.
$drh = DBI->install_driver("mysql");
$dsn = "DBI:mysql:database=homer;host=mysql.secureserver.net";
$dbh = DBI->connect($dsn,"root","simpson");
# Select the data and display to the browser
my $sth = $dbh->prepare("SELECT * FROM players");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref()) {
print "Found a row: id = $ref->{'id'}, name = $ref->{'name'}n";
}
$sth->finish();
# Disconnect from the database.
$dbh->disconnect();
_______________________________
When I run this from the cmd line I get
Content-type: text-html
*******************Connect Test
DBI connect('database=homer;host=mysql.secureserver.net','root',... failed:
Can't connect to MySQL server on 'mysql.secureserver.net' (10060) at connecttest.cgi line 12.
Thanks,
Jim