Re: php + postgresql
| От | Ivan Sergio Borgonovo |
|---|---|
| Тема | Re: php + postgresql |
| Дата | |
| Msg-id | 20080724174047.42b8b6e0@dawn.webthatworks.it обсуждение |
| Ответ на | Re: php + postgresql ("David Spadea" <david.spadea@gmail.com>) |
| Список | pgsql-general |
On Thu, 24 Jul 2008 11:13:52 -0400
"David Spadea" <david.spadea@gmail.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@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
В списке pgsql-general по дате отправления: