Re: php + postgresql

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: php + postgresql
Date: 2008-07-24 15:40:47
Message-ID: 20080724174047.42b8b6e0@dawn.webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 24 Jul 2008 11:13:52 -0400
"David Spadea" <david(dot)spadea(at)gmail(dot)com> wrote:

> Mick,
>
> As I haven't seen anyone else say it, I just wanted to throw this
> in.
>
> I'm not a PHP programmer, so I'm not very sure of PHP's scoping
> rules, but this looks to me like a variable scoping problem. If
> the first time you've used $content is inside of the while(), it's
> probably going out of scope before your echo. Try this:

ivan(at)dawn:~$ php -a
Interactive mode enabled

<?php
if(true) {
$content="it exixts";
}
print $content;
it exixts

The code and PHP scoping are not nice but it should prove that
scoping is not the problem ;)

> # Initialize $content before going into the loop.
> # This declares it outside the scope of the while()
>
> $content=''';

mistype

> # Now do your loop
>
> while ($row = pg_fetch_array($query)) {
> $content = $row[0]
> }
>
> echo $content;
>
>
>
> Your loop is a little weird, too. You're not accumulating anything,
> you're just saving the previous value. When you exit the loop,
> $content will only contain the value from the final row. If that's

for debugging I suggested:
$content .= $row[0]." # ";
So he could see if any row even if all $row[0] contained '' or null.

--
Ivan Sergio Borgonovo
http://www.webthatworks.it

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Neufeld 2008-07-24 15:42:59 Re: contrib catalogs
Previous Message M. François =?iso-8859-1?b?QmVub+50LU1hcmFuZA==?= 2008-07-24 15:36:21 Re: C function :: SECOND PROBLEM SOLVED :: SPI_finish releases memory!