简体   繁体   English

pg_connect致命错误使用PHP

[英]pg_connect fatal error using php

I have a Postgres 9.1 database running on a remote server. 我有一个在远程服务器上运行的Postgres 9.1数据库。 I am trying to help a programmer set up remote posting to a table using php on my hostgator account. 我正在尝试帮助程序员在hostgator帐户上使用php设置到表的远程发布。

I have modified the pg_hba.conf file on my postgres server to allow all connections from the ip address of my hostgator server using a password. 我已经修改了postgres服务器上的pg_hba.conf文件,以允许使用密码通过hostgator服务器的ip地址进行所有连接。

On hostgator, I am using a linux account and have modified the php.ini file to enable the line: 在hostgator上,我使用的是Linux帐户,并已修改php.ini文件以启用该行:

extension=php_pgsql.so 延长= php_pgsql.so

I have also tried this line: 我也尝试过这一行:

extension=php_pgsql.dll 延长= php_pgsql.dll

both with the following error: 两者都有以下错误:

Fatal error: Call to undefined function pg_connect() in /home1/kipsoft/public_html/hfs_forms/connection.php on line 6 致命错误:在第6行的/home1/kipsoft/public_html/hfs_forms/connection.php中调用未定义的函数pg_connect()

In order to enable the php.ini file for every domain, I did modify the .htaccess file as in the instructions: 为了为每个域启用php.ini文件,我确实按照说明修改了.htaccess文件:

# Use PHP55 as default
# Use PHP5 as default
AddHandler application/x-httpd-php5 .php
# BEGIN custom php.ini PHP55
<IfModule mod_suphp.c>
    suPHP_ConfigPath /home1/kipsoft
</IfModule>
# END custom php.ini

The connect script looks like this: 连接脚本如下所示:

<?php
session_start();
//$link = mysqli_connect('localhost', 'root', '', '209.239.000.001');
//$link = mysqli_connect('localhost', 'myuser', 'mypassword', 'myforms');

$db_connection = pg_connect("host=209.239.000.001 port=5432 dbname=myforms user=myuser password=mypassword");

/*if (!$link) {
    die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}*/

ini_set("memory_limit", "192M");
?>

Unfortunately, I know nothing about php and I think the programmer has no experience with postgres. 不幸的是,我对php一无所知,并且我认为程序员没有使用postgres的经验。 Anything to help would be greatly appreciated. 任何帮助将不胜感激。

Check if php-pgsql is installed. 检查是否安装了php-pgsql。 Run: 跑:

php –me

or 要么

yum list installed | grep php

If you don't see pgsql installed install it by running as root: 如果您没有看到安装的pgsql,请以root身份运行安装它:

yum install php-pgsql

Enable pgsql in php.ini - uncomment this line - note, that dll is for Windows only: 在php.ini中启用pgsql-取消注释此行-注意,该dll仅适用于Windows:

extension=php_pgsql.so

Restart apache: 重新启动Apache:

service httpd restart

Check if php-pgsql is working now. 检查php-pgsql是否现在可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM