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

572RE: [soaplite] Re: DBI and SOAP::LITE

Expand Messages
  • Chris Davies
    Jul 4, 2001
      Sorry, I'm puzzled. What can't you do? You should be able to test a CGI
      script that performs DBI accesses without needing to include SOAP. Something
      trivial would do to confirm interoperability. If this simple DBI program
      doesn't work (syntax errors excepted, of course) then it's clearly not a
      SOAP issue and you'll need to investigate the DBI problems elsewhere.

      use strict;
      use CGI::Carp;
      use DBI;

      my $dbh = DBI->connect (...) || die "connect: $DBI::errstr";
      my $sth = $dbh->prepare ("SELECT...") || die "prepare: $DBI::errstr";
      $sth->execute;

      print "Content-type: text/plain\n\n";
      while (my $row = $sth->fetchrow_hashref) {
      print map { "$_ = $row->{$_} } keys %$row, "\n";
      }
      $sth->finish;
      $dbh->disconnect;
      print "All done\n";
      exit 0;
      # E&OE of course

      I'll pick this up again tomorrow.
      Cheers,
      Chris


      -----Original Message-----
      From: caboose@... [mailto:caboose@...]
      Sent: Wednesday, July 04, 2001 5:23 PM
      To: soaplite@yahoogroups.com
      Subject: [soaplite] Re: DBI and SOAP::LITE



      If I could do that, I wouldn't be asking around.
      My problem is that the line DBI->connect
      ("DBI:mysql:database=delivery;host=brest.c-lab.de","root","")
      never completes execution. Whatever values (true or nonsense) I give
      for the paramaters it does nowt. I can even put in nonsense for the
      driver (mysql) it's still the same.

      It never gets to the ored die part.

      Any further line will never be exectuted. It seems to be stuck
      somewhere in the DBI: part and never get any further.

      Sabine

      --- In soaplite@y..., "Chris Davies" <Chris.Davies@M...> wrote:
      > Try including this near the top of the program:
      > use CGI::Carp qw(fatalsToBrowser)
      >
      > and then (later):
      > my $dbh =
      > DBI->connect("DBI:mysql:database=delivery;host=brest.c-
      lab.de","root","") ||
      > die "Cannot connect to database: $DBI::errstr";
      >
      > Ideally you'll want to catch all errors, so include {RaiseError =>
      1} in the
      > DBI attributes, or else check each return value:
      > my $sth = $dbh->prepare("SELECT * from documents WHERE
      name='$doc'") ||
      > die "Cannot prepare SELECT statement: $DBI::errstr";
      > $sth->execute() ||
      > die "Cannot execute statement: $DBI::errstr";
      >
      > As I mentioned in another email, if you're having problems with a
      CGI script
      > containing both DBI and SOAP, try isolating the problem. For
      example, check
      > that DBI works in your CGI script, and then check that SOAP works
      in your
      > CGI script. It's almost certainly an issue with the CGI script
      running
      > without necessary environment variables, or under a username that
      doesn't
      > have access to your database (or its tables).
      >
      > Chris
    • Show all 10 messages in this topic