Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
537 views
in Technique[技术] by (71.8m points)

php - Fatal error: Call to undefined function pg_connect

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:wampinphpphp5.3.5php.exe     C:wampwwwemail3.php','r');

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 :

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

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/",

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

Any suggestions are appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Apache 2.2.X configuration

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 Configuration

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

Restart WAMP

Test by adding this in your index.php

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...