jb489 Posted August 6, 2009 Share Posted August 6, 2009 Hi all, i have just made some sortware and am testing it live. I have a connection string like so which is in a config file: host=test.com user=testu password=testp dbname=testdb When i try to connect using this code: public function getDataSet($ConnectionString, $Query) { $DataArr = array(); $conn = pg_connect($ConnectionString); try{ if (!$conn) { throw new Exception("Error Connecting to database. Please check configuration file."); } else { $result = pg_query($Query); if (!$result) { throw new Exception("No user matches the search."); } else { $numrows = pg_numrows($result); for ($i=0; $i < $numrows ; $i++) { $DataArr[] = pg_fetch_assoc($result, $i); } pg_close($conn); return $DataArr; } } } catch(Exception $e) { pg_close($conn); throw new Exception($e->getMessage()); } } I get back this error: pg_connect(): Unable to connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host "xxx.xxx.xxx.xxx", user "testu", database "testdb", SSL off I cannot change the pg_hba.conf file as this means restarting their database server which is out of the question. any ideas ? Link to comment https://forums.phpfreaks.com/topic/169110-not-connecting-to-database/ Share on other sites More sharing options...
ram4nd Posted August 6, 2009 Share Posted August 6, 2009 You have wrong connection string. Link to comment https://forums.phpfreaks.com/topic/169110-not-connecting-to-database/#findComment-892287 Share on other sites More sharing options...
jb489 Posted August 6, 2009 Author Share Posted August 6, 2009 wrong in what way ? Link to comment https://forums.phpfreaks.com/topic/169110-not-connecting-to-database/#findComment-892293 Share on other sites More sharing options...
jb489 Posted August 6, 2009 Author Share Posted August 6, 2009 i have changed it now to: host=test.com user=user password=password dbname=db sslmode=require port=5432 and get this error: pg_connect(): Unable to connect to PostgreSQL server: sslmode value "require" invalid when SSL support is not compiled in but the postgres database has it inbuilt for sure as i connect to it with pgadmin3 and the ssl option as required and it works Link to comment https://forums.phpfreaks.com/topic/169110-not-connecting-to-database/#findComment-892296 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.