pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Keary Suska <hierophant@pcisys.net>
To: Postgres-PHP <pgsql-php@postgresql.org>
Subject: Re: help !!!
Date: Mon, 17 Jun 2002 11:10:56 -0600
Message-ID: <B9337440.F991%hierophant@pcisys.net> (raw)
In-Reply-To: <3D0DB73A.2050108@province.ru>

on 6/17/02 4:17 AM, sasha@province.ru purportedly said:

> function PaperList () {
> global $db;
> $str = "select gazeta.id as i,gorod.id as ig,trim(gazeta.name,'
> ') as gaz_n, trim(gorod.name,' ') as gor_n from gazeta,gorod where
> gazeta.id_gorod=gorod.id order by gazeta.name asc;";
> $result = pg_Exec( $db, $str );
> if ($result = pg_Exec( $db, $str ) != false && ($num =
> pg_numrows($result)) ) {
> for ($i = 0; $i < $num; $i++) {
> $r = pg_fetch_object($result, $i);
> ^^^^^   -- here get error message
> echo "<OPTION VALUE=$r->i> $r->gor_n / $r->gaze_n\n";
> };
> };
> };
> 
> Supplied argument is not a valid PostgreSQL result resource in ib.inc
> Can any one explain that  !!!!

Are you sure the offending line is the one you think it is? Line numbers
reported can be misleading since PHP looks at lines differently than most
text editors. There could possibly be an obscure precedence issue with your
if() statement. I recommend getting rid of the first pg_exec call (you are
actually calling the query twice--the pg_exec in the if() statement executes
the query a second time), and changing the if() statement:

if ( $result = pg_exec( $db, $str ) and $num = pg_numrows($result) ) {
  for ($i = 0; $i < $num; $i++) {
    $r = pg_fetch_object($result, $i);
    echo "<OPTION VALUE=$r->i> $r->gor_n / $r->gaze_n\n";
  };
};

Note the changed if() statement. This should clarify the precedence.

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"




view thread (16+ messages)  latest in thread

Message-ID: <B9337440.F991%hierophant@pcisys.net>
Permalink:  ../B9337440.F991%25hierophant@pcisys.net/
Also on:    postgresql.org/message-id/B9337440.F991%hierophant@pcisys.net

 · 

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: hierophant@pcisys.net
  Subject: Re: help !!!
  In-Reply-To: <B9337440.F991%hierophant@pcisys.net>
  References: <3D0DB73A.2050108@province.ru> <B9337440.F991%hierophant@pcisys.net>

* 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