从 ubuntu 服务器调用我的 php 脚本时出现此错误。我已经使用 apt get 安装了 php5-pgsql,但错误仍然存在。以下是我的源代码,请帮忙。
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$host = "localhost";
$port = "5432";
$user = "postgres";
$pass = "root";
$db = "quickbed";
$con = pg_connect("host=$host port=$port dbname=$db user=$user password=$pass") or die ("Could not connect to server\n");
$query = "select * from tbl_hosts, (select count(*) from tbl_hosts) as cnt order by registration_time";
$rs = pg_query($con, $query) or die("Cannot execute query: $query\n");
$rows['spaces'] = pg_fetch_all($rs);
echo json_encode($rows);
pg_close($con);
?>
最佳答案
您必须安装 PostgreSQL 模块并启用它。
http://php.net/manual/en/pgsql.installation.php
关于php - fatal error : Uncaught Error: Call to undefined function pg_connect(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44842054/