RE: Connection issues with pgsql?

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

 



I'd suggest building a connection string, explicitly defining the user and
password.  Maybe it would give you a more descriptive error that way
("invalid user", etc.).

The other thing I've done is do something like this:

$database = pg_connect ($conn_string)
	or die ("Help! No connection to the database! Error: " .
pg_last_error());


That may give you some more diagnostic info?

dwb
> -----Original Message-----
> From: Nathaniel Price [mailto:seoman@myrealbox.com]
> Sent: Friday, March 28, 2003 2:05 PM
> To: php-db@lists.php.net
> Subject:  Connection issues with pgsql?
> 
> 
> Hi, I just installed PHP with pgsql support, and it doesn't 
> seem to work
> properly, although I don't see why it shouldn't.
> 
> I'm running the following script:
> <?php
> error_reporting (E_ALL);
> $myconn = pg_connect("dbname=thornvalley");
> $res = pg_query('select * from test;', $myconn);
> print_r(pg_fetch_row($res));
> ?>
> 
> and this is what I get back:
> Warning: pg_query(): supplied argument is not a valid PostgreSQL link
> resource in /var/www/html/dbtest.php on line 4
> 
> Warning: pg_fetch_row(): supplied argument is not a valid 
> PostgreSQL result
> resource in /var/www/html/dbtest.php on line 5
> 
> without any other clues as to what might be happening. I have 
> tried using
> other connection strings as well:
> "dbname=thornvalley user=apache password=[passwd]"
> "dbname=thornvalley user=apache password=[passwd] 
> host=localhost port=5432"
> 
> with the same result.
> 
> I'm not sure what's going on; just so that you know, I'm 
> using the RPM-based
> install of Apache 2.0.44, PHP 4.3.1 and PostgreSQL 7.3.2 that 
> comes with
> Mandrake Linux 9.1. All of the necessary support packages 
> (AFAIK) have been
> installed and are visible with phpinfo() (i.e. there's a 
> pgsql section), and
> I have defined an apache user in the PostgreSQL database... 
> so, any clues as
> to what might be going on?
> 
> ________________________________________
> Nathaniel Price http://www.thornvalley.com
> "Who is General Failure and why is he reading my hard drive?"
> 
> 
> -- 
> 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