From: | Keary Suska <hierophant(at)pcisys(dot)net> |
---|---|
To: | Postgres-PHP <pgsql-php(at)postgresql(dot)org> |
Subject: | Re: help !!! |
Date: | 2002-06-17 17:10:56 |
Message-ID: | B9337440.F991%hierophant@pcisys.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php |
on 6/17/02 4:17 AM, sasha(at)province(dot)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"
From | Date | Subject | |
---|---|---|---|
Next Message | Cornelia Boenigk | 2002-06-17 18:18:01 | Re: help !!! |
Previous Message | Keary Suska | 2002-06-17 16:29:12 | Re: Getting array variables from my postgresql function |