PEAR Packages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Codewalkers ForumsPHP RelatedPEAR Packages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Old February 19th, 2009, 01:12 AM
kclee kclee is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Feb 2009
Posts: 4 kclee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 11 m 57 sec
Reputation Power: 0
DB Error: extension not found

When I invoked DB::connect with the DSN like mysql://xxx:yyy@localhost/test, I got an error
message of "DB Error: extension not found".

I wonder whether the mysql extension is correctly
loaded, and check this by PEAR::loadExtension('mysql').
The return value is FALSE, meaning mysql could not
be loaded. I also check DB::assertExtension('mysql'),
and the function is simply undefined. (Fatal error: Call to undefined method DB::assertextension())

It seems that the mysql extension is not loaded. Am I
missing any package? How could I load the mysql extesion?
Any help is appreciated. Thanks.

Reply With Quote
Old February 19th, 2009, 02:41 AM
wiesemann wiesemann is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 186 wiesemann User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 4 m 20 sec
Reputation Power: 12
The installation is explained in the PHP manual:
http://www.php.net/manual/en/mysql.installation.php

Reply With Quote
Old February 19th, 2009, 03:48 AM
kclee kclee is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Feb 2009
Posts: 4 kclee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 11 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by wiesemann
The installation is explained in the PHP manual:


I'm not quite sure I have installed mysql properly, but I guess I have. The problem may be concerned with the php PEAR package.

I installed php, mysql, pear, pear DB in Fedora 10 using the following commands:
yum -y install mysql mysql-server mysql-devel
yum -y install httpd php php-mysql php-devel

Then I tried mysql_connect using the following php script and it worked well:

PHP Code:
<?php
$link 
mysql_connect('localhost''xxx''yyy');
if (!
$link) {
    die(
'Could not connect: ' mysql_error());
}
?>


I installed php-pear using Add/Remove Software because yum does not know php-pear.

I use the following command to list the pear packages I have installed:
% pear list
INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET:
=========================================
PACKAGE VERSION STATE
Archive_Tar 1.3.2 stable
Auth 1.6.1 stable
Auth_HTTP 2.1.6 stable
Console_Getopt 1.2.3 stable
DB 1.7.13 stable
MDB2 2.4.1 stable
PEAR 1.7.2 stable
Structures_Graph 1.0.2 stable


The problem is what the error message ("DB Error: extension not found") means and how to solve this error while executing the following php script (I really created a database named test in the mysql database):

PHP Code:
<?php
require_once( "/usr/share/pear/DB.php" );
$db DB::connect("mysql://xxx:yyy@localhost/test",false);
?>


Any help is appreciated.

Reply With Quote
Old February 19th, 2009, 04:57 AM
wiesemann wiesemann is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 186 wiesemann User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 4 m 20 sec
Reputation Power: 12
Quote:
Originally Posted by kclee
PHP Code:
<?php
$link 
mysql_connect('localhost''xxx''yyy');
if (!
$link) {
    die(
'Could not connect: ' mysql_error());
}
?>


That's interesting. Does phpinfo() show the mysql block in its output?

Quote:
Originally Posted by kclee
The problem is what the error message ("DB Error: extension not found") means [...]


This error is raised in the following case:
- DB::connect() calls PEAR::loadExtension('mysql')
- PEAR::loadExtension('mysql') has the following check: extension_loaded($ext) (with $ext being 'mysql' in your case)
- if the check fails, PEAR tries to load the extension via PHP's dl() function

Therefore, can you please tell us what the output of
var_dump(extension_loaded('mysql'));
in your script is?

Just to be sure: Are you running both example scripts (with and without PEAR and DB) on the same server? (And not e.g. one via CLI.)

BTW:
Quote:
Originally Posted by kclee
require_once( "/usr/share/pear/DB.php" );


This should just be the following:
require_once( "DB.php" );

If it doesn't work this way, your include_path setting is wrong. DB might work with your call then, but e.g. MDB2 or other PEAR packages won't (because they can't find their files for inclusion).

Reply With Quote
Old February 19th, 2009, 09:33 AM
kclee kclee is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Feb 2009
Posts: 4 kclee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 11 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by wiesemann
That's interesting. Does phpinfo() show the mysql block in its output?


Yes. The content of mysql block is:

MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version 5.0.67
MYSQL_MODULE_TYPE external
MYSQL_SOCKET /var/lib/mysql/mysql.sock
MYSQL_INCLUDE -I/usr/include/mysql
MYSQL_LIBS -L/usr/lib/mysql -lmysqlclient



Quote:
Originally Posted by wiesemann
This error is raised in the following case:
- DB::connect() calls PEAR::loadExtension('mysql')
- PEAR::loadExtension('mysql') has the following check: extension_loaded($ext) (with $ext being 'mysql' in your case)
- if the check fails, PEAR tries to load the extension via PHP's dl() function

Therefore, can you please tell us what the output of
var_dump(extension_loaded('mysql'));
in your script is?


the output is "bool(false)",
How to load mysql?

Quote:
Originally Posted by wiesemann
Just to be sure: Are you running both example scripts (with and without PEAR and DB) on the same server? (And not e.g. one via CLI.)


Yes. Both "mysql_connect" and "DB::connect" are run on the same server and "mysql_connect" works well.
But "DB:connect" is run using popen("php test.php 1","r").


Quote:
Originally Posted by wiesemann
BTW:

This should just be the following:
require_once( "DB.php" );

If it doesn't work this way, your include_path setting is wrong. DB might work with your call then, but e.g. MDB2 or other PEAR packages won't (because they can't find their files for inclusion).


The include_path is:
include_path = ".:/usr/local/lib/php:/usr/share/pear/"

But somehow require_once( "DB.php" ); doesn't work.
So I cange that to require_once( "/usr/share/pear/DB.php");


Thanks.
Any help is appreciated.

Last edited by kclee : February 19th, 2009 at 09:43 AM.

Reply With Quote
Old February 19th, 2009, 10:10 AM
wiesemann wiesemann is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 186 wiesemann User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 4 m 20 sec
Reputation Power: 12
Quote:
Originally Posted by kclee
the output is "bool(false)",
How to load mysql?


You don't need to load it yourself. If phpinfo() shows it, the extension is loaded.

Quote:
Originally Posted by kclee
But "DB:connect" is run using popen("php test.php 1","r").


Okay, that's the problem. You're using the CLI version of PHP with this call. This version has it's own php.ini file, and might be differently configured, i.e. without MySQL support. Calling "php -m" should show you a list without the item "mysql".

Solution: The CLI version of PHP needs the MySQL extension.

Quote:
Originally Posted by kclee
The include_path is:
include_path = ".:/usr/local/lib/php:/usr/share/pear/"

But somehow require_once( "DB.php" ); doesn't work.
So I cange that to require_once( "/usr/share/pear/DB.php");


Maybe you changed the wrong include_path. You need to modify the setting of the CLI version.

Reply With Quote
Old February 20th, 2009, 02:29 AM
kclee kclee is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Feb 2009
Posts: 4 kclee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 11 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by wiesemann
Solution: The CLI version of PHP needs the MySQL extension.


I found that the default dynamic library of CLI version of PHP is /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ and the CLI version of PHP's Configuration File (php.ini) Path in the server is /usr/local/lib.

When I tried `php -d 'extension_dir=/usr/lib/php/modules' -d 'extension=mysql.so' test.php` then no error message shows.

How to configure the /usr/local/lib/php.ini so that mysql extension (/usr/lib/php/modules/mysql.so) can be loaded by CLI version of PHP? (my test result shows that directly coping /etc/php.ini to /usr/local/lib/ doesn't work)

Thanks you very much.

Any help is appreciated.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPEAR Packages > DB Error: extension not found


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap