php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15282 pg_connect failing on iPlanet 4.1 nsapi
Submitted: 2002-01-29 13:56 UTC Modified: 2002-02-04 11:30 UTC
From: daver at qunara dot com Assigned: yohgaki (profile)
Status: Not a bug Package: PostgreSQL related
PHP Version: 4.1.1 OS: Solaris 2.8
Private report: No CVE-ID: None
 [2002-01-29 13:56 UTC] daver at qunara dot com
When attempting to connecting to a remote database using pg_connect(host=dbhost user=dbuser dbname=dbname), the operation fails.

I can connect using psql from the command line or through a perl script as any user. Running php as a CGI binary also works. However, when running as an nsapi, the connection fails. A quick look using snoop shows that the failed connection appears to be sending SYN/RST instead of SYN/ACK (which is what is seen during a successful connection).

Here's my system details:
	OS: Solaris 2.8
	Web Server: iPlanet 4.1
	PHP version: php 4.1.1
	PHP configure options:
		./configure --with-nsapi=/usr/local/iws41 \
			--with-pgsql=/usr/local/pgsql \
			--enable-libgcc
	PostgreSQL version: 7.0.3
	
For what it's worth, connections to a mysql database between the same systems works without a hitch.

Any suggestions would be appreciated.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-29 20:42 UTC] yohgaki@php.net
Could you take a look at web server error log? 
Do you have anything related? (segfault, etc)

Could you run iPlanet under gdb? (to see if it is exting or segfaulting)

Do you quote connection string?
Do you get any error message from pg_connect? 
Do you have multiple libpq? (find / -name "libpq*")

Do you have the same problem with snapshot?
http://snaps.php.net/

Attach *complete* script even if it is a few lines next time.
 [2002-01-30 00:11 UTC] daver at qunara dot com
I've also tried using the current CVS (01/26/2002) with no luck. The are no multiple copies of libpq, it's a new system.

I haven't tried running iPlanet under gdb yet, that'll be something to try tommorow.

In the mean time, here's the error from the logs:

[29/Jan/2002:22:50:18] info (14848): for host b-39-117-res1.mts.net trying to POST /members.php, PHP_log_message reports: PHP Warning:  Unable to connect to PostgreSQL server:  connectDBStart() -- connect() failed: No such file or directory
        Is the postmaster running (with -i) at 'db1'
        and accepting connections on TCP/IP port 5432?
 in /usr/local/etc/httpd/htdocs/cardp.ca/members.php on line 100

No other errors appear and the server keeps on running.

The source of the script (sans-HTML) calling the database follows:


<?

	$db = pg_connect("host='db1' user='cardp' dbname='cardp'");
	if(!$db) {
		echo "\nAn error occured connecting to the database.\n";
		exit;
	}

	if($alpha=="Show All") {
	$query = "SELECT last_name, first_name, address1, address2, address3,
					city, province, country, postal_code, email 
				FROM members WHERE active = TRUE ORDER BY last_name";
	} else {
	$query = "SELECT last_name, first_name, address1, address2, address3,
					city, province, country, postal_code, email 
				FROM members WHERE active = TRUE AND last_name LIKE '$alpha%' ORDER BY last_name";
	}

	$result = pg_exec($db, $query);
	if(!$result) {
		echo "An error occured executing the query.\n";
		exit;
	}

	$numFields = pg_numfields($result);
	$numRows = pg_numrows($result);

	if($numRows > 0) {
		for ($rowCount=0; $rowCount < $numRows; $rowCount++) {
			$row = pg_fetch_array($result, $rowCount);
			if($rowCount % 2) {
				print("<tr>\n");
			} else {
				print("<tr class=\"shade\">\n");
			}
			print("<td align=left valign=top width=200>");
			print("<B>" . $row["last_name"] . ", " . $row["first_name"] . "</B></td>\n");
			print("<td align=left valign=top width=200>");
			if($row["address1"]) {
				print($row["address1"] . "<br>\n");
			}
			if($row["address2"]) {
				print($row["address2"] . "<br>\n");
			}
			if($row["address3"]) {
				print($row["address3"] . "<br>\n");
			}
			print($row["city"] . ", " . $row["province"]);
			if($row["postal_code"]) {
				print(" " . $row["postal_code"] . "<br>\n");
			}
			if($row["country"] != "Canada") {
				print($row["country"] . "<br>\n");
			}
			if($row["email"]) {
				print("<a href=\"mailto:" . $row["email"] . "\">" . $row["email"] . "</a>\n");
			}
			print("</td>\n</tr>\n");
		}
		if(!($numRows % 2)) {
			print("<tr><td colspan=2 class=\"shade\">&nbsp;</td></tr>\n");
		}
	} else {
		print("<tr><td align=center valign=middle colspan=2>\n");
		print("<h2>Sorry</h2>\n");
		print("<B>There were no results that matched your query.</B>\n");
		print("<P>Please make another selection.</P>\n");
		print("</td></tr>\n");
	}

?>

- DR
 [2002-01-30 01:24 UTC] yohgaki@php.net
This is not a bug but usual result with your configuration.
Read manual. It's explained :)
 [2002-01-30 18:02 UTC] daver at qunara dot com
It's in the manual? Could you please be a little more specific? I've gone through the manual and cannot find anything regarding these results from this configuration.

I've managed to get this to work on a linux system using the same configuration without encountering the same problem. However, this is not an option within our current production environment.
 [2002-02-04 11:30 UTC] daver at qunara dot com
As per your last question, yes. PostgreSQL is running with the -i option. Connections are successful from other systems (at least the 5 others I tried), but not using server parsed php. They are only successfull when using php from the comand line, using psql, or using perl.

- DR

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu May 23 23:01:26 2019 UTC