PHP warning for no reason!

Asked

Viewed 63 times

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 extension php_pgsql.dll is enabled, and if this is not the problem, try using only a string pg_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

  • You are passing pg_connect information as a function with multiple parameters, instead you should use a string, try to put . instead of ,

  • 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

  • You are concatenating wrong, http://www.tiexpert.net/programcao/web/php/concatenacao-e-operacoes-matematicas.php

  • forehead like this pg_connect("host=ovelha port=80 dbname=wmma user=postgres password=senha5");

  • Still on the same @Gabrielrodrigues :(

  • checked if the php extension is enabled ?

  • positive my friend! Everything ok (Y)

  • 1

    The postgres don’t work at door 80

  • 2

    generally and the 5432 @rray

  • @Gabrielrodrigues that there

  • 1

    BINGO! Vlw personal! Ratiei!

  • 1

    worked out? if the gate is the standard nor need to inform

Show 8 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.