致命错误:调用未定义函数pg_connect [英] Fatal error: Call to undefined function pg_connect

查看:279
本文介绍了致命错误:调用未定义函数pg_connect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows 7,php 5.3.5和WAMP服务器.我有两个php文件:trigger.php和background.php.
我想将background.php作为后台进程运行.我必须从trigger.php调用此文件.为此,我使用了以下方法. 我在trigger.php中包含了以下代码,以使background.php在后台进行处理.

I am using Windows 7, php 5.3.5 and WAMP server. I have two php files: trigger.php and background.php.
I want to run background.php as a background process. I have to call this file from trigger.php. To accomplish this I used below method. I included following code in trigger.php to make background.php to process in background.

$handle = popen('start /b C:\wamp\bin\php\php5.3.5\php.exe     C:\wamp\www\email3.php','r');

在background.php中,我有下面的代码可以连接到数据库.

in background.php I have the follwing code to connect to database.

$conn_string = "host=localhost port=5432 dbname=tagbase user=postgres password=postgres";  

现在,在解析此行时出现以下错误:

now, on parsing this line am getting the follwing error :

致命错误:在第3行的C:\ wamp \ www \ background.php中调用未定义的函数pg_connect()调用堆栈:0.0002 322792 1. {main}()C:\ wamp \ www \ background.php: 0

Fatal error: Call to undefined function pg_connect() in C:\wamp\www\background.php on line 3 Call Stack: 0.0002 322792 1. {main}() C:\wamp\www\background.php:0

通过在互联网上搜索,我找到了一些解决方案,并按照以下php.ini中的建议进行了更改,

By searching in in the internet I found some solutions, and made changes as recommended below in php.ini,

uncommented, extension=php_pdo_pgsql.dll,
uncommented, extension=php_pgsql.dll,
uncommented, extension_dir = "c:/wamp/bin/php/php5.3.5/ext/",

我也确实在c:/wamp/bin/php/php5.3.5/ext/文件夹中有php_pdo_pgsql.dll和php_pgsql.dll文件.

also I do have php_pdo_pgsql.dll and php_pgsql.dll files in c:/wamp/bin/php/php5.3.5/ext/ folder.

任何建议都值得赞赏.

推荐答案

Apache 2.2.X配置

将下一行添加到Apache 2.2.x httpd.conf配置中:

Add the next line to the Apache 2.2.x httpd.conf configuration:

LoadFile "C:/Program Files/PostgreSQL/{version}/bin/libpq.dll"

必须在下一行之前输入上一行.

Above line must be entered before the next line.

LoadModule php5_module "c:/wamp/bin/php/php5.2.11/php5apache2_2.dll"

PHP 5.2.X配置

在php.ini配置文件中启用以下两行.我的意思是启用",删除结尾; (分号).通过这些,您可以取消注释行.

Enable the following two lines in the php.ini configuration file. By 'Enable' i mean, remove trailing ; (semicolon). By these, you un-comment the line.

extension=php_pdo_pgsql.dll
extension=php_pgsql.dll

重新启动WAMP

通过将其添加到index.php中进行测试

Test by adding this in your index.php

echo extension_loaded('pgsql') ? 'yes':'no';

(来源: http://www.plaatsoft.nl/wamp-postgresql-integration/)

这篇关于致命错误:调用未定义函数pg_connect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆