Hi,
This stuff is pretty new to me , but you could try this :

use DBI;

my $database = "mydatabase" ;
my $servername = "localhost" ;
my $username = "username" ;
my $password = "password" ;

$dbh = DBI->connect("DBI:mysql:database=$database;host=$servername ,
$username , $password) ;

It's all there : perldoc DBD::mysql

Can't find anything about the "or die ..." bit.

Good luck , Frank.

On Wed, 14 Nov 2001 12:43:52 +0000, "A Taylor"
<[EMAIL PROTECTED]> wrote:
>I am tring to connect to a MySql database and I have been told that I
have 
>to include the 'HOSTNAME' (localhost). Can anyone see anything wrong
with 
>this code ??????
>
>use DBI;
>
>my $database    = 'mydatabase@localhost';
>my $data_source = "DBI:mysql:$database";
>my $username    = "username";
>my $password    = "password";
>
>my $dbh = DBI->connect($data_source, $username, $password)
>       or die "unable to connect to database: " . DBI->errstr;
>
>When i run the code, it bombs out at the 'my $dbh = ....'
>
>Many many thanks in advance (I have spent days on this !!!!)
>Anadi
>
>
>_________________________________________________________________
>Get your FREE download of MSN Explorer at
http://explorer.msn.com/intl.asp
>
>
>-- 
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to