Results 1 to 2 of 2

Thread: Referencing a PHP Class inside a PHP Include

  1. #1
    rickpugh's Avatar
    rickpugh is offline Practically a Glow Sage
    Join Date
    Apr 2005
    Simi Valley, California, United States

    Talking Referencing a PHP Class inside a PHP Include

    Hi everyone,

    Thought that this would be a good place to see if any of you could help "educate" me on some of the more "creative" tricks with PHP.

    Here is the situation...

    I am setting up a full PHP Image Gallery. This gallery uses a MySQL Database and has a php front end. It is very nice. I am really doing this little effort to teach myself more about PHP and MySQL. I already have a working Gallery that I really like for my site so this is really just an educational effort on my part.

    I have hit a snag:

    The Gallery runs on four different PHP Class Files. They are:

    1. MySQLHandler.class.php
    2. Photogallery.class.php
    3. ImageHandler.class.php
    4. BBCodes.class.php

    Each of these classes performs pretty much as named. Each of these classes are included into the main PHP code by being required in the "header.include.php" file that is at the top of every page:

    Here is what the header code looks like:

    PHP Code:
    $MySQLHandler = new MySQLHandler();
    $ImageHandler = new ImageHandler($MySQLHandler);
    $SZBBCodes = new SZBBCodes();
    $SZPhotoGallery = new SZPhotoGallery($MySQLHandler$ImageHandler$SZBBCodes);
    $page = isset($_GET['page']) ? $_GET['page'] : false;
    $photo_category_id = isset($_GET['photo_category_id']) ? $_GET['photo_category_id'] : false
    Here is where I am having the problem. I don't know how to refer to the location of the class files in the above code. I have tried using document root, local path, and http location but have had no luck.

    I did a little research on the PHP web site and saw some posting in the comments section from various people that they have had the same problem. Unfortunately, no one has posted any type of solution.

    Here are the errors that I am getting:

    Please note that the paths that are specified in this error message have been changed. I provide accurate path/file locations below.

    Warning: main(): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/ricknlis/public_html/rick/new/spm/ebay/images/inc/ on line 2
    Warning: main(): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/ricknlis/public_html/rick/new/spm/ebay/images/inc/ on line 2
    Fatal error: main(): Failed opening required '' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/ricknlis/public_html/rick/new/spm/ebay/images/inc/ on line 2
    To make any type of comments or replies easier, here is some more info:

    1. The class files are located in "public_html/rick/ebay/images/"
    2. The php image gallery files are located in "public_html/rick/ebay/images/"
    3. The include file that references the class files above is located in "public_html/rick/ebay/images/inc/"

    So here is what I am looking to find out:

    1. In the code situation above, what type of directory path should be specified?

    2. Should I change from sing quote ( ' ) to double quote ( " ) for different types of path formats?

    3. In PHP, what does ( ./ ) represent? Is it the same as ../ in unix?

    Thanks everyone in advance!

    Last edited by Matt; 10-20-2007 at 12:37 PM.

  2. #2
    jmarcv's Avatar
    jmarcv is offline Cranky Coder
    Join Date
    Jan 2005


    Same here, I can help you out if you still need it. Sorry I didn't catch this last spring <g>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16