Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在WebMatrix php中连接到postgres数据库?_Php_Postgresql_Heroku_Webmatrix - Fatal编程技术网

如何在WebMatrix php中连接到postgres数据库?

如何在WebMatrix php中连接到postgres数据库?,php,postgresql,heroku,webmatrix,Php,Postgresql,Heroku,Webmatrix,我不确定如何通过WebMatrix创建的本地服务器连接到heroku上的数据库。当我的应用程序托管在heroku上时,如果我运行php脚本,我就有代码连接到数据库工作。以下行失败: $dbconn=pg_connect(“主机=someEC2Instance.com端口=5432 dbname=xxxxxxx用户=xxxxxxx密码=xxxxxxxxx sslmode=require选项='--client_encoding=UTF8')或die('无法连接:'.pg_last_error())

我不确定如何通过WebMatrix创建的本地服务器连接到heroku上的数据库。当我的应用程序托管在heroku上时,如果我运行php脚本,我就有代码连接到数据库工作。以下行失败:

$dbconn=pg_connect(“主机=someEC2Instance.com端口=5432 dbname=xxxxxxx用户=xxxxxxx密码=xxxxxxxxx sslmode=require选项='--client_encoding=UTF8')或die('无法连接:'.pg_last_error())


我想使用heroku上托管的数据库,有人知道这里出了什么问题吗?

正常情况下,数据库未配置为“外部”访问。我不太了解主持人heroku,但是:我想说你不能用你的Web服务器“从外部”访问数据库

你能发布完整的错误信息吗

您可以回显“pg_last_error”。。我打赌它说的是“连接被拒绝”或“连接超时”

要访问数据库,您应该在heroku上托管Web应用程序,或者在pc上本地安装数据库


问候。

Heroku的情况不是这样-它们允许直接连接数据库。pg_connect之后没有行执行,因此我无法输出pg_last_错误