I inastall php 5.4, apache and postgresql 9.2 on Windows 7 OS.
Now, I am trying connect to postgresql DB from php file, this is php connect code:
$dbconn = pg_connect("host=localhost dbname=postgres user=postgres password=pass");
This gives: Call to undefined function pg_connect()
In php.ini
file I have: extension="path\\to\\extension\\php_pgsql.dll"
What may causes this error?
I too have tried to connect to a database using pg_connect but I am getting Error: call to undefined function. I have used PDO to connect to database. This seems to work.
<?php
try {
$dbuser = 'postgres';
$dbpass = 'your password';
$host = 'localhost';
$dbname='dbname';
$connec = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);
}catch (PDOException $e) {
echo "Error : " . $e->getMessage() . "<br/>";
die();
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.