pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Lynna Landstreet <lynna@gallery44.org>
To: pgsql-php@postgresql.org
Subject: Vexing PHP problem - browser hangs.
Date: Wed, 16 Jul 2003 16:44:30 -0400
Message-ID: <BB3B316E.576%lynna@gallery44.org> (raw)

Hi folks,

I'm running into trouble with a bit of PHP code that ought to be simple and
probably is to anyone who actually knows what they're doing, but is causing
my browser to hang every time I run it. The script in question follows; it's
supposed to query the artists table in my database and print a list of all
the artists, one per line, last name then first name. It also pulls up the
artist_id field because once I've gotten the damn thing to work at all, I'm
going to use that to link the names to artist info pages, but right now that
field isn't being used.

I know the connection to the database (which happens in the head section of
the document, not here) is being made successfully, because I tested that on
its own first. And the query is being made successfully, because I tested
that to, before I added the code to display the artists' names. It's that
part that is causing it to hang. I don't get any error message or anything,
the browser just "thinks" for an eternity, locking up my system while doing
so, until I eventually force-quit it.

Does anyone have any idea what might be going wrong? There is a fairly large
number of artist records (around 500), but I don't think that's it, because
when I tried changing the second expression in the for statement to row < 30
instead of row < pg_numrows($artist_list) to just print the first 30 names,
it didn't help. I'm hoping the problem is something simply that a more
experienced person could see easily and I'm just missing because I'm new at
this... 

Anyway, here's the code. BTW, the server has PostgreSQL 7.2 and PHP 4.1, so
some of the names of the PHP functions are different than they would be in
4.2.

      <?
        
          // queries the database, finds artists
      
          $query = "SELECT artist_id, firstname, lastname  FROM artists
ORDER BY lastname";
          $artist_list = pg_exec($db, $query);
          if ($artist_list) {
          
          // checks to see if any results where found
          
              if ( pg_numrows($artist_list) == 0)  {
                  echo "<p>Sorry, no artists were found.</p>";
              } else {
          
          // writes list
          
                  for ($row = 0; row < pg_numrows($artist_list); $row++) {
                       echo "<p>" . pg_result($artist_list, $row,
'lastname') . ", " . pg_result($artist_list, $row, 'firstname') . "</p>";
                }
          
          // adds total to bottom of list
          
                  echo "<p>Total results retrieved:" .
pg_numrows($artist_list) . "</p>";
          
              }
          
          // prints error message if query fails
          
          } else {
              echo "<p>The query failed with the following error
message:</p>";
              echo "<p>" . pg_errormessage($db) . "</p>";
          }       
      ?>

Thanks,

Lynna
-- 
Resource Centre Database Coordinator
Gallery 44
www.gallery44.org




view thread (9+ messages)  latest in thread

Message-ID: <BB3B316E.576%lynna@gallery44.org>
Permalink:  ../BB3B316E.576%25lynna@gallery44.org/
Also on:    postgresql.org/message-id/BB3B316E.576%lynna@gallery44.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: lynna@gallery44.org
  Subject: Re: Vexing PHP problem - browser hangs.
  In-Reply-To: <BB3B316E.576%lynna@gallery44.org>
  References: <BB3B316E.576%lynna@gallery44.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox