Home: Perl Programming Help: DBI:
Attempted database (mysql) connection brings up a blank screen

New User

Mar 16, 2004, 5:45 PM

Views: 9719
Attempted database (mysql) connection brings up a blank screen

The code:

print "Content-type:text/html", "\n\n";

use DBI;

# set the data source name
# format: dbi:db type:db name:host:port
# mysqls default port is 3306
# if you are running mysql on another host or port,
# you must change it
my $dsn = 'DBI:MySQL:peterhawkesDB:mysql.seanet.com:3306';

# set the user and password
my $user = 'peterhawkes';
my $pass = '*****';

# now connect and get a database handle
my $dbh = DBI->connect($dsn, $user, $pass)
or die "Cant connect to the DB: $DBI->errstr \n";

print "Successful MySQL DB Connection <BR> \n";

exit 0;


Have to trust my password is correct.
I have tried mysql.seanet.com and localhost for the hostname (which have been verified by seanet as correct).
I have tried MySQL as MySQL and mysql (worried about case sensitive issues) and DBI as DBI and dbi.
I use AceFTP for FTP'ing of files to my seanet webserver.

Had problems initally FTP'ing perl scripts at the beginning, but used ASCII and changed the properties on perl scripts to READ all, WRITE user, EXECUTE all.

My belief is that it cannot connect and the error does not show up in the html.

I was wondering if the problem was in the way I FTP the script OR the properties associated with the file?

Anyone got ideas why I return a blank webpage page from this?


Thaumaturge / Moderator

Mar 16, 2004, 10:57 PM

Views: 9718
Re: [peterhawkes] Attempted database (mysql) connection brings up a blank screen

The error message is probably ending up in you web server error log. Have you tried looking in there?

Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks

New User

Mar 16, 2004, 11:30 PM

Views: 9716
Re: [davorg] Attempted database (mysql) connection brings up a blank screen

I am having the web server log retrieved.

Thank you for this lead.

Can we rule out the way I FTP the scripts to the web server (in ASCII)?

New User

Mar 17, 2004, 2:50 PM

Views: 9711
Re: [peterhawkes] Attempted database (mysql) connection brings up a blank screen

Well looking at the logs explained everything and then talking to the person who initially gave me the host name information was not correct.

it was bosco.seanet.com

but this information made little difference as looking in the log, their server does not support Perl->DBI applications.

Can't locate object method "connect" via package "DBI" at databaseconnectionmethod2.pl line 16.
install_driver(mysql) failed: Can't load '/usr/libdata/perl5/site_perl/i386-bsdos/auto/DBD/mysql/mysql.so' for module DBD::mysql: File not found at /usr/libdata/perl5/5.00503/i386-bsdos/DynaLoader.pm line 169.

I'm a bit disgruntled by this. I knew my code was fine...above was just a snippet of the larger code. Originally I used an MSAccess ODBC connection on my local webserver at home, but FTP'ing it to the webserver at seanet brought these complications. A great learning experience ! For all perl coders, your code may be right, but they may not have the drivers ;-).

On a side note, I installed this great windows connector app from mysql.com which allows you to test mysql ODBC connections putting in hostname, port no, database name, user name, and password. You hit the test button to see if the database connects or not ! Then you know whether they have the mysql drivers you need ;-)