Loading ...
Sorry, an error occurred while loading the content.

Re: Perl DBI with Apache ASP

Expand Messages
  • Helmut Zeilinger
    Hi, what does DBI::errstr say ? E.g. ... $DBH=DBI- connect($dsn,$user,$pwd); print DBI::errstr; # prevent the script from dying in the subsequent
    Message 1 of 3 , May 22 11:12 PM
    • 0 Attachment
      Hi,

      what does DBI::errstr say ?

      E.g.

      ...
      $DBH=DBI->connect($dsn,$user,$pwd);
      print DBI::errstr;

      # prevent the script from dying in the subsequent $dbh->execute();
      $Response->End();
      ...


      By the way:

      - I would not use a global variable $DBH rather than a private "my
      $DBH".
      What happens, if a second script (in another apache child) is
      calling "$DBH->execute" just after in the first script
      "$DBH-disconnect()" was done?


      Helmut



      > 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
      > postmaster@...
      > ******************************************************************************




      ---------------------------------------------------------------------
      To unsubscribe, e-mail: asp-unsubscribe@...
      For additional commands, e-mail: asp-help@...
    Your message has been successfully submitted and would be delivered to recipients shortly.