Re: DB interface problem

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

 



Hi Giff,

No worries - I know the feeling well!

At first glance this looks OK, however I notice that there is no "res" property defined in the STH class, like there is session and query.

$this->res on line 202 is what's causing the issue - PHP is saying it's not a valid PostgreSQL result resource, so if you trace back to where that comes from, you get to line 175:

$this->res = @pg_execute($this->session, $query);

PHP is therefore trying to assign a query result to a property that doesn't exist. I would have expected PHP to throw an error at this but it may have been obscured with your logging settings, I'm not sure.

Try adding "public $res;" after line 85 and see what you get. You could also add "var_dump($this->res);" between lines 175 and 176 which should tell you what PHP thinks "$this->res" is.

And lastly, you could get a back-trace of the rows() method call to see if it's being called before $this->res has been assigned - just add the line "var_dump(debug_backtrace());" between lines 201 and 202.

Hope this gives you a starting pointer!

Regards,
Andy

On 27 October2009, at 19:36, Giff Hammar wrote:

Andy,

Sometimes I'm too fast for my own good. I added .txt to the file and it
should be visible as http://www.sv-phoenix.com/dbi_pgsql.txt. Just
appending the .txt didn't work.

Thanks for taking a look!

Giff

On Tue, 2009-10-27 at 17:49 +0000, Andy Shellam (Mailing Lists) wrote:
Hi Giff,

I want to have a look at this for you, but you'll need to put the file
on your server as plain-text because your server is parsing the PHP
code and only sending us the output, not the source code.

Append *.txt to your file on the server and we should be able to see
it better!

Andy

On 27 October2009, at 12:48, Giff Hammar wrote:

I started having trouble with a DBI interface to my PostgreSQL
database
after I built a new Ubuntu machine. The Postgres version is 8.3 and
the
DBI was written several years ago (by someone else). I'm using PHP
version 5.2.6-3ubuntu4.2 with apache2. The problem is that I get the
error:

Warning: pg_num_rows(): supplied argument is not a valid PostgreSQL
result resource in /var/www/lib/dbi_pgsql.php on line 202

I don't know what to check next to figure out why this is happening.
Here is what I have done so far:

- Updated the old PHP commands in the dbi file to reflect new ones
  var -> public
  pg_numrows -> pg_num_rows
  pg_cmdtuples -> pg_affected_rows
  pg_exec -> pg_execute
- Connected to the database as the same user by using straight PHP
calls
vs the DBI. It worked fine.
- Connected to the database via psql and that worked fine, too.

There is something with the DBI class that is not right, but I am a
novice with objects and classes, so I can't pin it down. The whole
file
is here: http://www.sv-phoenix.com/dbi_pgsql.php - it's 205 lines so I
didn't want to put the whole thing in this post.

If anyone can take a look at it and let me know what to check next, I
would really appreciate it.

Giff


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux