Apologies for the previous html.

On 30 Nov 2006 at 13:59, Also Sprach Narayana, Srimanrt License:

>   I am new to perl programming. Installed mysql,perl,mysql odbc
> drivers
> in my machine. Following is my code, its not working. I googled it but
> no use :(

Why use odbc?

Get the latest activestate perl and using the package manager get the latest 
DBI and
DBD-mysql packages.

Here's some code that will connect to your mysql db (not tested):

#! /usr/bin/perl -w 

use strict;
use diagnostics;

use DBI;


eval {


    my $dbh = DBI-
>connect('DBI:mysql:database=db_name;host=localhost;port=33
06',

                           'username',

                           'password',

                           {'RaiseError' => 1,

                            'PrintError' => 0,

                            'AutoCommit' => 0} );

}; # eval

( $@ ) {

   for my $dbh ( @dbhs ) {

       $dbh->rollback if $dbh;

   }

   die $@;

}

Reply via email to