ivanovn
asked on
PEAR and PostgreSQL
I have PHP 5.1.1 and I installed PEAR 1.4.9. Then I installed the DB 1.7.6 package to use with an application that would be accessing the PostgreSQL 8.1 database. This is all on Windows XP Pro.
However, when I run the application it does everything correctly, but when it comes to the part where it's supposed to connect to the datbase I get the following error:
DB Error: extension not found
I uncommented the php_pgsql.dll extension, and I set the extension_dir in php.ini. I restarted the Apache and I still get the same error.
What could be the issue?
Thanks.
However, when I run the application it does everything correctly, but when it comes to the part where it's supposed to connect to the datbase I get the following error:
DB Error: extension not found
I uncommented the php_pgsql.dll extension, and I set the extension_dir in php.ini. I restarted the Apache and I still get the same error.
What could be the issue?
Thanks.
Can you show us your code?
ASKER
Yes, the relevant database connection file is:
<?php
require_once 'DB.php'; //PEAR DB package
class DBConnection
{
function DSN()
{
$db_engine = 'pgsql';
$db_user = '<username>';
$db_pass = '<password>';
$db_host = '<ipaddress>';
$db_port = '5432';
$db_name = '<dbname>';
$datasource = $db_engine.'://'.
$db_user.':'.
$db_pass.'@'.
$db_host.':'.$db_port.'/'.
$db_name;
return $datasource;
}
function GetDBConnection()
{
$datasource = DBConnection::DSN();
$db_obj =& DB::connect($datasource, TRUE);
if(DB::isError($db_obj))
{
echo "Not Connecting To the DataBase. Please Try Again.". $db_obj->getUserInfo();
exit;
}
$db_obj->setFetchMode(DB_F ETCHMODE_A SSOC);
return $db_obj;
}
}
?>
The error is coming from the if(DB::isError($db_obj)) branch.
<?php
require_once 'DB.php'; //PEAR DB package
class DBConnection
{
function DSN()
{
$db_engine = 'pgsql';
$db_user = '<username>';
$db_pass = '<password>';
$db_host = '<ipaddress>';
$db_port = '5432';
$db_name = '<dbname>';
$datasource = $db_engine.'://'.
$db_user.':'.
$db_pass.'@'.
$db_host.':'.$db_port.'/'.
$db_name;
return $datasource;
}
function GetDBConnection()
{
$datasource = DBConnection::DSN();
$db_obj =& DB::connect($datasource, TRUE);
if(DB::isError($db_obj))
{
echo "Not Connecting To the DataBase. Please Try Again.". $db_obj->getUserInfo();
exit;
}
$db_obj->setFetchMode(DB_F
return $db_obj;
}
}
?>
The error is coming from the if(DB::isError($db_obj)) branch.
And all the credentials are correct? Can you try a quick test using standard calls rather than PEAR DB?
ASKER
Yes, I checked the credentials and I can make a connection using standard calls rather than PEAR DB.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, I figured out what the issue was. My php.ini file was in system32 and for some reason php kept looking for it in Windows directory. So none of the php.ini changes were implemented when restarting the Apache. Once I moved the file and enabled pgsql module everything worked.
Thanks for the help.
Thanks for the help.
OOI. Did the code I provide make any difference?
Create info.php as <?php phpinfo(); ?>
Run that through your browser and look for "Configuration File".
Create info.php as <?php phpinfo(); ?>
Run that through your browser and look for "Configuration File".
ASKER
I did not attempt the code you gave me.
I did create a file with phpinfo() and that's how I figured out the php.ini was not in a right place.
I did create a file with phpinfo() and that's how I figured out the php.ini was not in a right place.
Ok. You got it working anyway. Sorry I could get there more directly.
Well done and thanks for the points.
Well done and thanks for the points.