Re: works at command line but not in apache
| From: | Jim Lucas | Date: | Sun, 18 Mar 2007 09:23:19 +0000 |
| Subject: | Re: works at command line but not in apache | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-250770@lists.php.net to get a copy of this message | ||
rwhartung wrote:
Hi, I have this short php script: [op;ening <?php and closing ?> removed. $db = pg_connect('dbname=bpsimple user=minitwr password=RWHart') ; print $db . "<br />" . "\n" ; if ($db) {Show us the entire script that you are using from the cli and the web. Also, give us the error, if any, that you are getting from the web script. Jimprint 'Connection attempt succeeded.' . "<br />" . "\n" ;} else {print 'Connection attempt failed.'. "<br />" . "\n" ;} $query = 'SELECT fname, lname FROM customer' ; $result = pg_query($db, $query) ; while($myrow = pg_fetch_assoc($result) ) {print $myrow['fname'] . " " . $myrow['lname'] . "\n" ;} This works fine as a PHP script from the command line, but wrapped up in <html> </html> tags it refuses to connect with the database from within apache. All connections are local host. PHP otherwise works fine on the apache server and the code is identical on both the CL script and the test.php web page. Ideas? Where to start looking? TIA Bob well, how about showing us the code that doesn't work also, I know you said it was the same, but what you have here is an incomplete script.