Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: DBI can't catch error

by mje (Curate)
on Nov 26, 2012 at 13:27 UTC ( #1005655=note: print w/replies, xml ) Need Help??


in reply to DBI can't catch error

If you fail to connect $Dbh will be undef. If $Dbh is not undef, you connected. So check $Dbh not $DBI::err.

Replies are listed 'Best First'.
Re^2: DBI can't catch error
by gepebril69 (Scribe) on Nov 26, 2012 at 13:54 UTC

    ok, that easy.

    So simplified it will be something like

    # Connect to MySQL server $Dbh = DBI->connect($DSN, $Config{'MYSQL_USER'}, $Config{'MYSQL_PASSWD +'}, { PrintError => 0, RaiseError => 0 }); # Check if connect went ok if (defined ($Dbh)) { # Good print "Successful connection with DB"; } else { # Problem! print "We had an error connecting to DB: ".$DBI::errstr; exit; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005655]
help
Chatterbox?
[MidLifeXis]: MKE
[marto]: Milwaukee
[1nickt]: thx marto
[LanX]: Canada?
[MidLifeXis]: :-)
[MidLifeXis]: Not for a few years yet. Kids in school :-)
[LanX]: NQC
[MidLifeXis]: Is there internet access up there on the lakes? If I moved there I would like to be able to fish :-D
[LanX]: Not Quite Canada
[Discipulus]: have you been fired?!?

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (12)
As of 2017-03-23 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (286 votes). Check out past polls.