#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0

    Thumbs down Can't require DB.php


    Hi

    I'm working from a book which uses the PEAR module of PHP5.
    To connect to a database I first have to

    require 'DB.php';

    but this causes an error. My hosting company has told me the location of DB.php is

    /services/websoftware/zend.php5/pear/

    but when I include the line

    require '/services/websoftware/zend.php5/pear/DB.php';

    into a file that I know already works I still get an error.

    My Hosting company say I should mention the server is Apache Shared Hosting

    Can anyone help please?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,600
    Rep Power
    595
    Unlikely without the error message. Few of us are clairvoyant.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    Sorry!

    Error message as below.

    ERRNO: 2
    TEXT: require(/services/websoftware/zend.php5/pear/DB.php) [function.require]: failed to open stream: No such file or directory
    LOCATION: /services3/webpages/j/i/jillystackshop.com/public/index.php, line 36, at November 27, 2012, 3:12 pm
    Showing backtrace:
    require() # line 36, file: /services3/webpages/j/i/jillystackshop.com/public/index.php
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,600
    Rep Power
    595
    The error message is very clear. Regardless of what you were told that file is not in that path. Can you look in that path to see what is there? Is it possible the correct path is /services3/websoftware/zend.php5/pear/DB.php (a guess based on the location of your PHP script)? This is really a question for that system's admin.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    I already tried that but get same message. However now I have confidence to reply to the hostiong company that their info is wrong.

    Thanks for your help.
  10. #6
  11. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Location
    Seattle, U.S.A.
    Posts
    712
    Rep Power
    13
    Generally with pear you don't include the file directly, since many of the classes build upon each other. If the hosting company was correct (which they may not be). Then you'd want to include the pear path at the top of your script(s):

    PHP Code:
    ini_set'include_path'ini_get'include_path' ) . PATH_SEPARATOR "/services/websoftware/zend.php5/pear/" ); 
    After you finish the book, look into MDB2. DB has been deprecated in favor of MDB2.
  12. #7
  13. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Location
    Seattle, U.S.A.
    Posts
    712
    Rep Power
    13
    Oh and then once you have included the path to the pear directory, then you can just do:

    PHP Code:
    require_once 'DB.php'

    Do you have ssh access to your server? If the hosting company's pear directory is not working for you, you can install it locally in your users home directory and then use that path as your include instead of the hosting company's.

    Comments on this post

    • gw1500se agrees : Thanks for the additional notes on the pear perspective. I have not used it myself.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    Thanks, I'll give that a go and see what happens.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    Hi Msteudel

    I tried adding the path but got same error (2) "file does not exist"

    I am waiting for the hosting company (BT) to reply to my query that they have not given me the correct path.

    Thanks for your help
  18. #10
  19. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Location
    Seattle, U.S.A.
    Posts
    712
    Rep Power
    13
    Can you ftp and see what's in that directory? Could be they didn't install pear/db since it's deprecated.
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    No, I can't see the directory. However have now confirmed they gave me bad info and I am waiting for the correct path so I can start again!
  22. #12
  23. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Location
    Seattle, U.S.A.
    Posts
    712
    Rep Power
    13
    That's a bummer. I'd also look into some sort of local web server for development much more convienant. For Mac check out mamp for windows check out wamp or xamp
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    trouble is I need to use the clients host so I need to test "in situ" having previously been caught out by testing on my own installation of PHP and Apache where everything worked fine but the client's hosts server rejected most of my files!

IMN logo majestic logo threadwatch logo seochat tools logo