Title: Perl DBI with Apache ASP

Hello

I am working on an apache asp page that has a mysql database at the backend.  The problem I have is that the code does work but sometimes the error

        #  Can't call method "prepare" on an undefined value
appears and my page fails.

I know the code I have works because it runs several times then fails.  I have also established that the error is because the connection to the database failed.

The database is on the same system so network errors are not the problem.

The following is the code

my $price="";
  5: my $product="";
  6: my $ID="";
  7:
  8: if ($Request->Params('par'))
  9: {
 10:    $par=$Request->Params('par');
 11: }
 12: else
 13: {
 14:    $Response->Redirect('test.asp');
 15: }
 16:
 17: $price=$Request->Params('price');
 18: $product=$Request->Params('Product');
 19: $ID=$Session->{'user'};
 20:
 21: $DBH=DBI->connect($dsn,$user,$pwd);
 22:
 23: $sth=$DBH->prepare("Insert into wishlist(sessionID,product,price,pnumber,pcode,name) values ('$ID','$product','$price','not-set','$par','not-set')" );

 24:
 25:
 26: $sth->execute();
 27:
 28: $sth->finish;
 29: $DBH->disconnect;
 30:
 31: $Response->Redirect("test.asp?par=$par");
 32:

The DBI-connect parameters are setup in the global.asa file.  I had the connect statement in there too but I would get more refreshes and successful runs when it was in here then in the global.asa.  It seems to be intermittent for some reason. 

Again the code does do what it is supposed to most of the time but sometimes fails with the above error.

Can anyone help me on this.

Many thanks

Trevor Cushen
Sysnet Ltd

Telephone: 01-2983000


****************************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this message in error please notify SYSNET Ltd., at telephone no: +353-1-2983000 or [EMAIL PROTECTED] ******************************************************************************

Reply via email to