[PHP-DB] connectivity problem
Hey everyone, got a problem here. I'm using php4.2.1, postgres 7.2. I'm trying to do a simple database connect with the following small php script: -- htmlheadtitlePHP Test/title/head body ?php //connect to postgres database $conn=pg_connect(user=bnoecker dbname=brian); //see if our connection was successful if ($conn==false) { //connection failed - exit the page with an error echo pg_errormessage($conn); exit; } else if($conn) { echo I did it; } $sql=SELECT * FROM employee; $sql_result=pg_exec($conn.$sql) or die (Couldn't Execute Query.); I can manually run the SELECT * FROM employee string and get results with user bnoecker. I've granted all to bnoecker and as well added the postgres admin to the user=. In test, no password has been assigned. I do not get a connection failed message, in fact I do the the I did it message. I do however get the following as it tries to do the query: I did it Warning: pg_exec() query failed: ERROR: parser: parse error at or near resource in /home/bnoecker/public_html/hello.php on line 19 Couldn't Execute Query. Now, others use the same postgres instance with other databases from php scripts without issue, mostly using includes. Can someone show me what I may be overlooking. I'm new to php but I found examples where things are basically layed out like what I've got? Thanks, Brian -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] connectivity problem
look at http://www.php.net/manual/en/function.pg-connect.php do you have postgresql starting with the -i paramater so that it is listening on a TCP port? PHP needs this to be able to connect to postgresql. Adam On Tue, 27 Aug 2002, Brian Noecker wrote: Hey everyone, got a problem here. I'm using php4.2.1, postgres 7.2. I'm trying to do a simple database connect with the following small php script: -- htmlheadtitlePHP Test/title/head body ?php //connect to postgres database $conn=pg_connect(user=bnoecker dbname=brian); //see if our connection was successful if ($conn==false) { //connection failed - exit the page with an error echo pg_errormessage($conn); exit; } else if($conn) { echo I did it; } $sql=SELECT * FROM employee; $sql_result=pg_exec($conn.$sql) or die (Couldn't Execute Query.); I can manually run the SELECT * FROM employee string and get results with user bnoecker. I've granted all to bnoecker and as well added the postgres admin to the user=. In test, no password has been assigned. I do not get a connection failed message, in fact I do the the I did it message. I do however get the following as it tries to do the query: I did it Warning: pg_exec() query failed: ERROR: parser: parse error at or near resource in /home/bnoecker/public_html/hello.php on line 19 Couldn't Execute Query. Now, others use the same postgres instance with other databases from php scripts without issue, mostly using includes. Can someone show me what I may be overlooking. I'm new to php but I found examples where things are basically layed out like what I've got? Thanks, Brian -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] connectivity problem
In your connect statement, you aren't selecting a password and TCP port to connect to. You made need to specify those. Adam On Tue, 27 Aug 2002, Brian Noecker wrote: Hey everyone, got a problem here. I'm using php4.2.1, postgres 7.2. I'm trying to do a simple database connect with the following small php script: -- htmlheadtitlePHP Test/title/head body ?php //connect to postgres database $conn=pg_connect(user=bnoecker dbname=brian); //see if our connection was successful if ($conn==false) { //connection failed - exit the page with an error echo pg_errormessage($conn); exit; } else if($conn) { echo I did it; } $sql=SELECT * FROM employee; $sql_result=pg_exec($conn.$sql) or die (Couldn't Execute Query.); I can manually run the SELECT * FROM employee string and get results with user bnoecker. I've granted all to bnoecker and as well added the postgres admin to the user=. In test, no password has been assigned. I do not get a connection failed message, in fact I do the the I did it message. I do however get the following as it tries to do the query: I did it Warning: pg_exec() query failed: ERROR: parser: parse error at or near resource in /home/bnoecker/public_html/hello.php on line 19 Couldn't Execute Query. Now, others use the same postgres instance with other databases from php scripts without issue, mostly using includes. Can someone show me what I may be overlooking. I'm new to php but I found examples where things are basically layed out like what I've got? Thanks, Brian -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] connectivity problem
Hi Brian $sql_result=pg_exec($conn.$sql) or die (Couldn't Execute Query.); should be $sql_result=pg_exec($conn,$sql) or die (Couldn't Execute Query.); pg_exec($conn *comma not period* $sql)... Regards Conni -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php