PEAR doesn't seem to be working

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Charles

    #1

    PEAR doesn't seem to be working

    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('my sql://penguin:top^hat @db.example.com/restaurant');
    if (DB::isError($d b)) { 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,

  • Schluppy

    #2
    Re: PEAR doesn't seem to be working

    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('my sql://penguin:top^hat @db.example.com/restaurant');
    if (DB::isError($d b)) { 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:


    Specifically:


    --
    Schluppy

    Comment

    • Charles

      #3
      Re: PEAR doesn't seem to be working

      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.

      Comment

      • Schluppy

        #4
        Re: PEAR doesn't seem to be working

        On Thu, 25 Jan 2007 02:35:52 -0800, Charles wrote:
        >
        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_pa th 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\include s"

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



        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\include s;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




        Comment

        Working...