Search Postgresql Archives

Re: php + postgresql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 24 Jul 2008 11:13:52 -0400
"David Spadea" <david.spadea@xxxxxxxxx> 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



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux