Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

419
Visualizações
php pg_connect() works in terminal but not in the browser
<?php
    echo "Inside php file!<br>";

    $dbconn = pg_connect("host=localhost dbname=atharvacm user=atharvacm port=5432 password=Dominicmcs9") or die("Cannot connect to DB");

    echo "after con<br>";

    $query = "select * from person;";
    $result = pg_query($dbconn, $query) or die("cannot exec query");
    while ($answer = pg_fetch_row($result)) {
        echo $answer[0];
        echo $answer[1];
        echo " huh<br>";
    }
    echo "<br>end";
?>

this is the code im trying to execute. It outputs the records in the table person in terminal but in the browser it only echoes "Inside php file" and nothing after it.

Here is the terminal output:

atharvacm@kali:/var/www/html$ php psqltest.php 
Inside php file!<br>after con<br>1abc huh<br>2def huh<br>3pqr huh<br>4xyz huh<br><br>end
atharvacm@kali:/var/www/html$ 

Here is the output from the web browser

Inside php file!

Fatal error: Uncaught Error: Call to undefined function pg_connect() in /var/www/html/psqltest.php:4 Stack trace: #0 {main} thrown in /var/www/html/psqltest.php on line 4

I have kali linux and running apache2, psql, php7.

I installed the php-pgsql package and uncommented the extention in the php.ini file.

I cant seem to figure out what the problem is but my guess is that the pg_connect function is not finding the psql database or something form the browser. thanks!

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Please check the config.ini file of ur php configuration file "php.ini" within Apache Tomcat In some case the software is not configured for psql

So go in the file and uncomment the line Extension= pgsql

Also enable ur error log in Apache U can refer Please check the config.ini file of ur php configuration file "php.ini" within Apache Tomcat In some case the software is not configured for psql

So go in the file and uncomment the line Extension= pgsql

Also enable ur error log in Apache U can refer

Please check the config.ini file of ur php configuration file "php.ini" within Apache Tomcat In some case the software is not configured for psql

So go in the file and uncomment the line Extension= pgsql

Also enable ur error log in Apache U can refer

Please check the config.ini file of ur php configuration file "php.ini" within Apache Tomcat In some case the software is not configured for psql

So go in the file and uncomment the line Extension= pgsql

Also enable ur error log in Apache U can refer

How do I get PHP errors to display?

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda