0
I want to make a simple connection to the database but each time I test, after a long page load generates a Warning.
File database.class.php:
<?php
abstract class banco
{
public $servidor = "localhost";
public $usuario = "postgres";
public $porta = 80;
public $senha = "senha5";
public $nomebanco = "wmma";
public $conexao = NULL;
public $dataset = NULL;
public $linhasafetadas = -1;
public function __construct()
{
$this->conecta();
}
public function __destruct()
{
if($this->conexao != NULL){
pg_close($this->conexao);
}
}
public function conecta()
{
$this->conexao = pg_connect($this->servidor, $this->porta, $this->nomebanco, $this->usuario, $this->senha);
echo "Método Conecta foi chamado corretamente" . $this->conexao;
}
File test.class.php:
<?php
require_once("banco.class.php");
class teste extends banco
{
}
Test file.php:
require_once("classes/teste.class.php");
$testando = new teste();
As a result I have the following:
Warning: pg_connect(): Unable to connect to Postgresql server: server closed the Connection unexpectedly This probaly Means the server terminated abnormally before or while Processing the request. in ... banco.class.php on line 37
Already restarted apache and postgres, I thought it could be insistence on connection, but did not solve.
the problem is in function
pg_connect
first check if the php extensionphp_pgsql.dll
is enabled, and if this is not the problem, try using only a stringpg_connect('host=/tmp port=SUAPORTA dbname=SEUDB user=USER password=PASS');
with all parameters pre-configured to see if it is not a matter of mounting your string– Gabriel Rodrigues
You are passing pg_connect information as a function with multiple parameters, instead you should use a string, try to put
.
instead of,
– Gabriel Rodrigues
I changed the code to the following: $this->connection = pg_connect('host=/tmp. port=80. dbname=wmma. user=postgres. password=password5'); and I had the same result
– Hermus
You are concatenating wrong, http://www.tiexpert.net/programcao/web/php/concatenacao-e-operacoes-matematicas.php
– Gabriel Rodrigues
forehead like this
pg_connect("host=ovelha port=80 dbname=wmma user=postgres password=senha5");
– Gabriel Rodrigues
Still on the same @Gabrielrodrigues :(
– Hermus
checked if the php extension is enabled ?
– Gabriel Rodrigues
positive my friend! Everything ok (Y)
– Hermus
The postgres don’t work at door 80
– rray
generally and the
5432
@rray– Gabriel Rodrigues
@Gabrielrodrigues that there
– rray
BINGO! Vlw personal! Ratiei!
– Hermus
worked out? if the gate is the standard nor need to inform
– rray