Re: isError crashes on use in DB package
| From: | Arne de Bree | Date: | Wed, 30 Mar 2005 14:06:06 +0000 |
| Subject: | Re: isError crashes on use in DB package | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-18411@lists.php.net to get a copy of this message | ||
Which DB package version you use?
http://pear.php.net/package/DB/download/ says
the latest version depends
on php 4.2.0
Too bad Debian is so extreme slow updating their stable release to more
recent versions.
Gr,
Arne de Bree
> -----Oorspronkelijk bericht-----
> Van: brew@theMode.com [mailto:brew@theMode.com]
> Verzonden: woensdag 30 maart 2005 15:53
> Aan: PEAR general list
> Onderwerp: [PEAR] isError crashes on use in DB package
>
>
> I'm updating a website and plan to change it from mysql to postgresql
> and figure this is a good project to get my feet wet with the pear DB
> package. Formerly I'd used either the mysql or postgresl functions
> built into php.
>
> I played around with a simple pear DB script doing a SELECT on my
> development laptop and have it working, but when I put the same script
> on my production webserver it fails (but it occasionally runs a time
> or two and then starts failing again). Both machines run the stable
> version of Debian (Woody), namely:
>
> apache 1.3.26
> php 4.1.2
> postgresql 7.2.1
>
> The line in particular that is causing my script to fail is checking
> for errors on an object. Note that it's not failing on an error and
> executing the if statement, but rather executing isError seems to be
> causing the failure.
>
> if (PEAR::isError($db)) {
>
> or
>
> if (DB::isError($db)) {
>
>
> causes either a later error when I try to use the object in a query or
> I get (using lynx) 'Alert: Unexpected Network Read Error, connection
> aborted;' with no output to the browser.
>
> It's doesn't fail consistently, sometimes it runs, sometimes it
> crashes.
>
> Either one seems to work on my laptop. And if I comment out the error
> checking on the webserver script it runs fine, too.
> But, of course, I'd rather be checking for errors.
>
> I reloaded the php4 and the php4-pear packages on the webserver and
> restarted Apache and still get the same failures.
>
> My questions are:
>
> Which of the two error checking statements above should I be using.
> Does it matter? I'd guess since the object is created in the DB
> package that DB::isError would be the one, but the pear docs show it
> both ways in various places.
>
> How can I get the error checking code not to fail on the web server?
>
> Should I just give up on pear and go back to the php functions?
>
> Thanks for any suggestions... I've added the script on the end of this
> email just in case I'm doing something dumb.....
>
> brew
>
> <?php
>
> require_once 'DB.php';
>
> $user = 'mode';
> $pass = 'xxxxxxxx';
> $host = '';
> $db_name = 'mode';
>
> // Data Source Name: This is the universal connection string $dsn =
> "pgsql://$user:$pass@$host/$db_name";
> $db =& DB::connect($dsn);
>
> # this seems to be the offending line!
> if (PEAR::isError($db)) {
> die ($db->getMessage());
> }
>
> $db->setFetchMode(DB_FETCHMODE_ASSOC);
>
> print <<<EOS
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head>
> <title>Pear Test</title> </head> <body> <center> <h2> This
> is a Pear
> Test </h2> <table>
>
> EOS;
>
> $sql = "SELECT * from users ORDER BY user_id LIMIT 40"; $result =&
> $db->query($sql);
>
> // Always check that $result is not an error # this seems to be
> another offending line!
> if (PEAR::isError($result)) {
> die ($result->getMessage());
> }
>
> // Get each row of data on each iteration while ($row =&
> $result->fetchRow()) {
> $id = $row['user_id'];
> $email_adr = $row['email_adr'];
> print "<tr><td>$id</td><td>$email_adr</td></tr>
> \n"; }
>
> // You can disconnect from the database with:
> $db->disconnect();
>
> ?>
>
> </table>
> </center>
> </body>
> </html>
>
>
>
> ==============================================================
> ============
> Strange Brew (brew@theMode.com)
> Check out my Stock Option Covered Call website
> http://www.callpix.com
> and my Musician's Online Database Exchange
> http://www.TheMode.com
> ==============================================================
> ============
>
> --
> PEAR General Mailing List (http://pear.php.net/) To
> unsubscribe, visit: http://www.php.net/unsub.php
>
>
>