| View previous topic :: View next topic |
| Author |
Message |
slorio
Joined: 02 Sep 2006 Posts: 1
|
Posted: Sun Sep 03, 2006 7:55 am Post subject: DB.php giving me huge head ache! (please help) |
|
|
I just started learning PHP and mysql and using pear 2 days ago.
I get an error When i run the following code:
| Code: |
<?php
include('db_login.php');
require_once("DB.php");
$connection = DB::connect("mysql://$db_username:$db_password@$db_host/$db_database");
if (DB::iserror($connection)){
die ("could not connect to the database: <br/>".DB::errormessage($connection));
}
...
|
Everything was working just fine until i decided to try out PEAR.
The following is the error i get:
Fatal error: Class 'DB' not found in C:\Documents and Settings\Administrator\My Documents\komodo files\section_9.2.php on line 6.
Line 6 is:
| Code: |
DB::connect("mysql://$db_username:$db_password@$db_host/$db_database");
|
I installed WAMP SERVER 1.6.4 with the default setup.
I then installed KOMODO 3.5.3, build 262321, platform win32-x86
Everything works fine with database connectivity.
I decided to use PEAR, so i installed it and installed all packages and updates all packages. All are Stable.
Below is my Directory structure:
C:\wamp\
C:\wamp\apache2
C:\wamp\php
C:\wamp\mysql
C:\wamp\php\php.ini
C:\wamp\php\pear\
C:\wamp\php\pear\DB.php
php.ini contents:
| Code: |
include_path = ".;c:\php\includes;C:\wamp\php\PEAR"
|
Windows global PATH:
| Code: |
C:\Program Files\ActiveState Komodo 3.5\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Common Files\Adobe\AGL;C:\Program Files\Panda Software\Panda Titanium 2006 Antivirus + Antispyware\;C:\WINDOWS\DPDrv;C:\Program Files\ATI Technologies\ATI.ACE\;C:\wamp\php;c:\wamp\php\pear
|
DB.php ONLY works when i do the following:
| Code: |
require_once("c:\wamp\php\pear\DB.php");
|
Please post your ideas.
Thank you in advance!
Steve. |
|
| Back to top |
|
 |
shazam
Joined: 10 Jan 2007 Posts: 3
|
Posted: Wed Jan 10, 2007 9:58 pm Post subject: |
|
|
Slorio,
I am not sure how you went about installing PEAR, but you could take a look at how it is configured by running 'pear config-show' from the command line.
Here is an example of my output:
| Code: | C:\USR\php>pear config-show
CONFIGURATION (CHANNEL PEAR.PHP.NET):
=====================================
Auto-discover new Channels auto_discover <not set>
Default Channel default_channel pear.php.net
HTTP Proxy Server Address http_proxy <not set>
PEAR server [DEPRECATED] master_server pear.php.net
Default Channel Mirror preferred_mirror pear.php.net
Remote Configuration File remote_config <not set>
PEAR executables directory bin_dir C:\usr\php\pear
PEAR documentation directory doc_dir C:\usr\php\pear\docs
PHP extension directory ext_dir C:\usr\php\pear\ext
PEAR directory php_dir C:\usr\php\pear
PEAR Installer cache directory cache_dir C:\usr\php\pear\cache
PEAR data directory data_dir C:\usr\php\pear\data
PEAR Installer download download_dir C:\usr\php\temp\download
directory
PHP CLI/CGI binary php_bin C:\usr\php
PEAR Installer temp directory temp_dir C:\usr\php\temp
PEAR test directory test_dir C:\usr\php\pear\tests
Cache TimeToLive cache_ttl 300
Preferred Package State preferred_state stable
Unix file mask umask 0
Debug Log Level verbose 1
PEAR password (for password <not set>
maintainers)
Signature Handling Program sig_bin c:\gnupg\gpg.exe
Signature Key Directory sig_keydir C:\WINDOWS\pearkeys
Signature Key Id sig_keyid <not set>
Package Signature Type sig_type gpg
PEAR username (for username <not set>
maintainers)
User Configuration File Filename C:\WINDOWS\pear.ini
System Configuration File Filename C:\WINDOWS\pearsys.ini |
Perhaps it is installed, but not configured?
- B |
|
| Back to top |
|
 |
PearNoob
Joined: 02 Nov 2007 Posts: 5
|
Posted: Fri Nov 02, 2007 5:14 pm Post subject: |
|
|
Hi I have the same problem as slorio does. I am using Windows and have inputted the "Include_path = " in my php.ini file. I have also tried to download db.php file from pear.php.net/package section, but the download file only comes in .tar extension...
Also, I've run go-pear.bat, and following shazam, it seems that my Pear is not configured. Any info on how I would go about doing this?
| mark wrote: | The correct require_once call is this one:
| Code: |
require_once('DB.php');
|
To make this work, you need to adjust your include_path setting. The PEAR manual and a search in the forum will give you more details about this.
Your example code could fail for two reasons (both related to the include_path issue):
- PEAR.php is not found: you should see this error if you have error_reporting = ALL and display_errors = 1 settings
- one file of the DB packages isn't found: this error is silenced (with @) by default; you can turn this silencing off, by using connect(..., array('debug' => 2)); |
This seems to be from a related/same problem; I have also changed the Require_once code to where my Pear installation folder is but it doesn't work. Also, there doesn't seem to be a DB.php file! Any help is greatly appreciated. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1000
|
Posted: Fri Nov 02, 2007 7:07 pm Post subject: |
|
|
Well, without installing PEAR (and then the DB package), you won't have it on your system. Therefore, your next steps should be:
- install PEAR
- use it to install the DB package
- configure your include_path correctly (i.e. not to an empty string)
.tar can be unpacked also on Windows, but this is not the recommended way for installing PEAR packages. |
|
| Back to top |
|
 |
PearNoob
Joined: 02 Nov 2007 Posts: 5
|
Posted: Fri Nov 02, 2007 9:05 pm Post subject: |
|
|
I thought that running go-pear.bat would install all the files needed for running PEAR? If not, can you please tell me how to install PEAR; I looked on the PEAR website manual and the documentation wasn't very explicit.
"To make PEAR work on Windows, you simple need to add the PEAR installation dir (e.g. c:\php\pear) to the include_path directive in your php.ini."
I've done that but it didn't help. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1000
|
Posted: Fri Nov 02, 2007 9:21 pm Post subject: |
|
|
Did you restart your webserver after modifying the include_path?
About go-pear.bat: Yes, it should install PEAR. Did you get any output from it? If not, there seem to have gone something wrong. |
|
| Back to top |
|
 |
PearNoob
Joined: 02 Nov 2007 Posts: 5
|
Posted: Fri Nov 02, 2007 9:46 pm Post subject: |
|
|
Yes, I ran go-pear.bat and it ran though properly..."install ok", etc..
Also,
The 'pear' command is not currently in your PATH, so you need to use '.../php/pear.bat' until you have added '.../php' to your PATH environment variable.
And the error still exists after restarting my webserver (WAMP), after modify the php.ini configuration. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1000
|
Posted: Fri Nov 02, 2007 9:54 pm Post subject: |
|
|
Hmm, just to avoid confusion, did you run "pear install DB"?
BTW: The DB package is deprecated. It is recommended to use MDB2, although DB is currently still maintained and works good, but the future is MDB2. |
|
| Back to top |
|
 |
PearNoob
Joined: 02 Nov 2007 Posts: 5
|
Posted: Fri Nov 02, 2007 10:04 pm Post subject: |
|
|
Good thing you mentioned "pear install DB", because no, I haven't; I only ran "go-pear.bat". -_-
Conducted a search on my hard drive and I couldn't find "pear install DB" though, and I actually downloaded MDB2 package not DB from the PEAR website ^^ |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1000
|
Posted: Fri Nov 02, 2007 10:52 pm Post subject: |
|
|
| PearNoob wrote: | | Conducted a search on my hard drive and I couldn't find "pear install DB" though, |
You won't find it. Search for pear.bat, and add the directory in which you find it to your PATH setting (or simply switch to this directory in your command line). Then type "pear install MDB2", hit ENTER, wait some seconds, and MDB2 will be installed.
| PearNoob wrote: | | and I actually downloaded MDB2 package not DB from the PEAR website ^^ |
You don't need to download it. |
|
| Back to top |
|
 |
PearNoob
Joined: 02 Nov 2007 Posts: 5
|
Posted: Fri Nov 02, 2007 10:59 pm Post subject: |
|
|
Ahaha thanks, it started installing and then:
Fatal error: Allowed memory size of 8000000 byes exhausted (tried to allocate 100000 byes) on line 177.
So I think I just need to install this and DB function should work then? Thanks mark, you've been alot of help! |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1000
|
Posted: Fri Nov 02, 2007 11:10 pm Post subject: |
|
|
| PearNoob wrote: | Ahaha thanks, it started installing and then:
Fatal error: Allowed memory size of 8000000 byes exhausted (tried to allocate 100000 byes) on line 177. |
memory_limit setting in php.ini is your friend here.
| PearNoob wrote: | | So I think I just need to install this and DB function should work then? |
Right. |
|
| Back to top |
|
 |
|