PDA

View Full Version : Handling mySQL errors?


ilya
03-02-2000, 12:14 PM
If i remember correctly, PHP has something like mysql_error() - a function,that will display an exact error when trying to connect or do anything w/ mySQL.
Is there anything similar to that in Perl?

urban
03-02-2000, 12:51 PM
If you're using DBI, you can call errstr();

$DBI::errstr (or $dbh->errstr)


$dbh = DBI->connect($datasource,$username,$password)
or die "Can't connect to $datasource: $DBI::errstr\n";[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]


Note that the current version of DBI should automatically report database errors, unless you modify the PrintError or RaiseError values on connection.