help !!!

help !!!

am 17.06.2002 12:17:30 von sasha

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 "

Re: help !!!

am 17.06.2002 19:10:56 von Keary Suska

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 "

Re: help !!!

am 17.06.2002 20:18:01 von Cornelia Boenigk

Hi Alxander

> $r = pg_fetch_object($result, $i);
This syntax is valid since PHP 4.2.0. Are you sure that you use no
older PHP-Version?


> $result = pg_Exec( $db, $str );
> if ($result = pg_Exec( $db, $str ) != false && ($num =
> pg_numrows($result)) ) {

In the second line of the code-snippet you execute pg_exec a second
time. Write instead:

$result = pg_Exec( $db, $str );
if ($result && ($num = pg_numrows($result))) {

Regards
Conni


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Re: help !!!

am 18.06.2002 09:58:37 von sasha

Keary Suska wrote:

>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 "