homepage Welcome to WebmasterWorld Guest from 54.227.141.230
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
$DBI::errstr
Use of uninitialized value $DBI::errstr
parrot




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

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

 

DrDoc




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

Or, don't concatenate it if it doesn't exist or is undefined ...

parrot




msg:4596124
 4:45 pm on Jul 24, 2013 (gmt 0)

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;
}

DrDoc




msg:4596148
 5:43 pm on Jul 24, 2013 (gmt 0)

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.

parrot




msg:4596409
 12:45 pm on Jul 25, 2013 (gmt 0)

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

Regards,

Ton

phranque




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved