Welcome to WebmasterWorld Guest from 50.16.112.199

Forum Moderators: coopster & jatar k & phranque

$DBI::errstr

Use of uninitialized value $DBI::errstr

   
10:45 am on Jul 24, 2013 (gmt 0)

10+ Year Member



Hey Guys, I am having a small problem in my log files. when executed I get the error "Use of uninitialized value $DBI::errstr in concatination (.)....

It it possible to pre initialize the $DBI::errstr value to avoid the errors in my logfile?

Cheers,

Ton
4:36 pm on Jul 24, 2013 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Or, don't concatenate it if it doesn't exist or is undefined ...
4:45 pm on Jul 24, 2013 (gmt 0)

10+ Year Member



Hey there, here is an example of the code.

if (($ErrNum eq "0") and ($NewMember eq "1")){
$CartContent = 0;
$Dbh = DBI->connect($DbConnectionInfo,$DbUserid,$DbPasswd);
$Sth = $Dbh->prepare("SELECT ArtikelCode FROM $DbCarts WHERE Login = '$Login#$Wachtwoord'");
$Sth->execute or
$ErrNum = "3003";
$ErrMess = " ### Kritieke systeemfout!
### Program: '$PrgName' - Err: $ErrNum
### $DBI::errstr";
while (($ArtikelCode) = $Sth->fetchrow_array){
if ($ArtikelCode ne ""){
$ErrNum = "3004";
$ErrMess = " ### Kritieke systeemfout!
### Program: '$PrgName' - Err: $ErrNum
### Login of password zijn al in gebruik!
### Ga terug en kies een andere combinatie!";
}
}
$Sth->finish();
$Dbh->disconnect;
}
5:43 pm on Jul 24, 2013 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Exactly. You are concatenating the string whether it exists/is defined or not.

$ErrMess = " ### Kritieke systeemfout! 
### Program: '$PrgName' - Err: $ErrNum
### " . (defined $DBI::errstr ? $DBI::errstr : '');

You should likely delegate error handling to a separate method anyway, but that's a different discussion.
12:45 pm on Jul 25, 2013 (gmt 0)

10+ Year Member



Mmm, error keeps comming back. Isnt it possible to pre initialize once at the beginning of the script or dbase action?

Regards,

Ton
8:40 pm on Jul 25, 2013 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



you don't really want to preinitialize, you want an "if defined" test when using it in a variable assignment as suggested by DrDoc.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month