homepage Welcome to WebmasterWorld Guest from 54.145.191.14
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
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

5+ Year Member



 
Msg#: 4596033 posted 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

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



 
Msg#: 4596033 posted 4:36 pm on Jul 24, 2013 (gmt 0)

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

parrot

5+ Year Member



 
Msg#: 4596033 posted 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

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



 
Msg#: 4596033 posted 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

5+ Year Member



 
Msg#: 4596033 posted 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

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



 
Msg#: 4596033 posted 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.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved