【发布时间】:2011-02-24 06:53:39
【问题描述】:
我想从php 到postgres 连接到远程数据库,但它无法连接并说
Warning: pg_connect() [function.pg-connect]: Unable to connect to PostgreSQL server:
could not connect to server: No route to host (0x00002751/10065) Is the server running on host "xxxxxxxxx" and accepting TCP/IP connections on port 5432? in C:\xampp\htdocs\test.php on line 4
Wrong CONN_STRING
<html>
<body>
<?php
$db = pg_connect('host=xxx.xxx.xxx.xxx port=5432 dbname=postgres user=postgres password=') or die('Wrong CONN_STRING');
if (!$db) {
echo 'error';
}else{
echo 'success';
}
?>
</body>
我可以从pgadmin 客户端访问相同的数据库,该客户端在运行 apache 的同一台机器上运行,我无法理解 pgadmin 可以访问 db 但 apache webserver 的 php 无法访问?有什么想法吗?
【问题讨论】:
标签: php connection phppgadmin