php connect postgresql via command line but cant via apache

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

php connect postgresql via command line but cant via apache

Postby eMurat » 11. October 2020 10:19

There is an interesting situation, if I run the php code from the command line it connects to the database, but when I try it from the browser it won't connect.

I have a very simple link code actually, I use it to try it out:

This is the code:
Code: Select all
$dbconn = pg_connect("host=localhost port=5432 dbname=DBNAME user=postgres password=XXXXX")   
/* if cant connect */
or die('Could not connect: ' . pg_last_error());

/* if connect : */
echo 'connection is success';


If I run this code from the command line it works fine:
Image

But when I run it from the browser it doesn't work properly.
Image


Has anyone encountered this error and knows the solution?
eMurat
 
Posts: 1
Joined: 11. October 2020 09:56
XAMPP version: 5
Operating System: macos

Return to XAMPP for macOS

Who is online

Users browsing this forum: No registered users and 3 guests