By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,033 Members | 994 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,033 IT Pros & Developers. It's quick & easy.

PEAR doesn't seem to be working

P: n/a
I installed PHP with PEAR support on my Windows computer. I tried the
snippet of the book "Learning PHP5":

<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
echo "test";
include 'DB.php';
$db = DB::connect('mysql://penguin:to*****@db.example.com/restaurant');
if (DB::isError($db)) { die("Can't connect: " . $db->getMessage( )); }
?>

But it only prints "test", it should display an error message saying
it's not able to connect to the DB. Do you know why nothing happens?
Also, I think there should be a real "DB.php" file, correct? What
should I put into this file? Or is it only a line "as is", that doesn't
mean there needs a "DB.php" file?
Thanks,

Jan 24 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Wed, 24 Jan 2007 07:49:52 -0800, Charles wrote:
I installed PHP with PEAR support on my Windows computer. I tried the
snippet of the book "Learning PHP5":

<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
echo "test";
include 'DB.php';
$db = DB::connect('mysql://penguin:to*****@db.example.com/restaurant');
if (DB::isError($db)) { die("Can't connect: " . $db->getMessage( )); }
?>

But it only prints "test", it should display an error message saying
it's not able to connect to the DB. Do you know why nothing happens?
Also, I think there should be a real "DB.php" file, correct? What
should I put into this file? Or is it only a line "as is", that doesn't
mean there needs a "DB.php" file?
Thanks,
You need to read the docs:
http://pear.php.net/manual/index.php

Specifically:
http://pear.php.net/manual/en/installation.php

--
Schluppy

Jan 25 '07 #2

P: n/a
Specifically:http://pear.php.net/manual/en/installation.php

Thanks, this is what I followed yesterday. But it doesn't say in the
docs if there are PHP files and if they need to be put in a specific
place.

Jan 25 '07 #3

P: n/a
On Thu, 25 Jan 2007 02:35:52 -0800, Charles wrote:
>Specifically:http://pear.php.net/manual/en/installation.php

Thanks, this is what I followed yesterday. But it doesn't say in the
docs if there are PHP files and if they need to be put in a specific
place.
Generally, each pear package contains a set of php files. By default
they're installed in the pear folder hierarchy. Once installed you have to
ensure that the include_path directive in your php.ini contains that path.
Then you can include the files as per usual.

From the manual:

"include_path string

Specifies a list of directories where the require(), include() and
fopen_with_path() functions look for files. The format is like the
system's PATH environment variable: a list of directories separated
with a colon in Unix or semicolon in Windows.

Example G-1. Unix include_path

include_path=".:/php/includes"

Example G-2. Windows include_path

include_path=".;c:\php\includes"

Using a . in the include path allows for relative includes as it means
the current directory."

http://www.php.net/manual/en/ini.core.php

So, assuming you're on windows and your pear directory is in c:\php\pear,
you'd edit the include_path directive in your php.ini to read:

include_path=".;c:\php\includes;c:\php\pear"

If you're using apache you'll want to restart it for the changes to take
effect.

Now in your scripts, you can include any pear packages you've installed
exactly like the documentation for the package specifies.

--
Schluppy


Jan 25 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.