Problem connecting PostgreSQL and PHP

Using this question from CountZero, it looks like I am facing the same problem here. When my site tries to open a database connection, SOMETIME (not always), I get the following error:

Warning: pg_connect () [function.pg-connect]: cannot connect to the PostgreSQL server: the server unexpectedly closed the connection This probably means that the server is anonymous before or during processing the request. in E: \ htdocs \ trial_pg \ client_1a.php on line 3

Here is my client1a.php script:

<?php
  $connString = 'dbname=movies user=xxxxxx password=xxxxxx';
  $connHandler = pg_connect($connString);
  echo 'Connected to '.pg_dbname($connHandler);
?>

This often happens, especially when I reload the page (F5) to check the connection. I am new to postgresql and this is the development environment of my site:

OS: Windows 7 Professional

-: Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1

PHP: 5.3.1

PostgreSQL: 8.4.3

- , ? ?

!

+3
2

, ;)

:)

, , , : D

+4

, TCP-. , ?

0
source

Source: https://habr.com/ru/post/1764012/


All Articles