Solved

Why does PEAR DB give "DB Error: extension not found [DB Error: extension not found].."

Posted on 2011-03-09
10
4,215 Views
Last Modified: 2012-05-11
I'm moving a small set of PHP/Postgres applications from Ubuntu 9.x to 10.10. When I try to run the application, I get this error:

DB Error: extension not found [DB Error: extension not found] ** pgsql://jean@/appx

The code is:

            require_once('DB.php');
            $db=DB::connect("pgsql://jean@/appx");
            if (PEAR::isError($db)) {
                      die($db->getMessage()."  ".$db->getUserInfo()." ");
            }
            if (DB::isError($db)){
                        die($db->getMessage());
            }

When I installed DB, I noticed that it's been supersceded by MDB2, what do I have to change to make it work with MDB2, or what do I need to do make the DB code work?

Thanks.

Jean
0
Comment
Question by:JPNeron
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 21

Expert Comment

by:Julian Matz
ID: 35100871
Hi JPNeron,

See if the following works for you:

$ sudo aptitude install php5-psql

(Inside a terminal window, of course)
0
 

Author Comment

by:JPNeron
ID: 35101174
When I used 'php5-psql' as the package name, it said there was no such package. On a hunch, I tried 'php5-pgsql' instead, and it did download & install it, but I still get the error.
0
 
LVL 21

Expert Comment

by:Julian Matz
ID: 35105854
Sorry, it's more likely you're missing the Pear extension. My guess is that when you upgraded, the php extension directory probably changed. If this is the case, you'll need to reinstall the DB package. However, what I would do is try the MBD2 package first. If that fails, just re-install DB.

$ pear install MDB2

Make sure there are no errors, and take note of whether Pear has enabled the extension for you or not. You can post the last couple of lines from the output here.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:JPNeron
ID: 35105891
Both those packages appear to be installed:

root@Ubuntu:/home/jean# pear install MDB2
pear/MDB2 is already installed and is the same as the released version 2.4.1
install failed
root@Ubuntu:/home/jean# pear install DB
pear/DB is already installed and is the same as the released version 1.7.13
install failed

If DB was missing, wouldn't I get an error on the require_once('DB.php') statement?

Also, just to clarify, I'm not upgrading a machine, I have a brand new machine and I copied the php pages from the old server to the new server.
0
 
LVL 21

Accepted Solution

by:
Julian Matz earned 500 total points
ID: 35106104
You're right.

I think I've figured it out though. First, you do actually need the package php5-pgsql. Secondly, you also need php5-mysql. Without MySQL support, PHP in Ubuntu won't support PgSQL either, apparently.

$ sudo aptitude install php5-pgsql php5-mysql

Now, if you want to use MDB2 instead of DB, it's fairly straight forward. Just do the following:

$ sudo pear install pear/MDB2

And then:

$ sudo pear install pear/MDB2#pgsql

Then you need to change your code to following:

            require_once('MDB2.php'); // CHANGE THIS LINE
            $db=MDB2::connect("pgsql://jean@/appx"); // CHANGE THIS LINE ALSO
            if (PEAR::isError($db)) {
                      die($db->getMessage()."  ".$db->getUserInfo()." ");
            }
            if (MDB2::isError($db)){ // AND THIS ONE
                        die($db->getMessage());
            }

Open in new window


Hope that fixes it for you.
0
 

Author Comment

by:JPNeron
ID: 35109848
We have progress!

Now I get:


MDB2 Error: connect failed _doConnect: [Error message: unable to establish a connection] ** pgsql(pgsql)://jean:xxx@/appx

Not sure what the problem is here. This user can run psql, access the 'appx' database, view tables, etc, etc. Maybe there's a problem in the postgres setup that prevents connections from apache?
0
 
LVL 21

Expert Comment

by:Julian Matz
ID: 35111125
Would you be able to temporarily switch back to DB? It seems to me that DB does error reporting more constructively than MDB2, by default anyway.

Perhaps there's a setting to make MDB2 spit out more details, but I'm not sure where to look for that. But if we can get it working with DB, we should then be able to get it working with MDB2 also.

I'm assuming you have PostgreSQL installed?

$ sudo aptitude install postgresql

0
 

Author Comment

by:JPNeron
ID: 35112504
Hooray! Just switching back to DB solved the problem, everything works as it should!

I guess the problem all along was I needed to install the php5-mysql package.

Thanks for the help!
0
 

Author Closing Comment

by:JPNeron
ID: 35112514
The problem was the missing php5-mysql part of PEAR. After installing that, it was not necessary to change anything.
0
 
LVL 21

Expert Comment

by:Julian Matz
ID: 35112523
Good stuff! Glad I could help.
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question