Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

423
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda