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:

require('./MySQLHandler.class.php');
require('./SZPhotoGallery.class.php');
require('./ImageHandler.class.php');
require('./SZBBCodes.class.php');
$MySQLHandler = new MySQLHandler();
$MySQLHandler->init();
$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(http://rick.ricknlisa.com/new/spm/e...ndler.class.php): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/ricknlis/public_html/rick/new/spm/ebay/images/inc/header.inc.php on line 2

Warning: main(http://rick.ricknlisa.com/new/spm/e...ndler.class.php): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/ricknlis/public_html/rick/new/spm/ebay/images/inc/header.inc.php on line 2

Fatal error: main(): Failed opening required 'http://rick.ricknlisa.com/new/spm/ebay/images/inc/MySQLHandler.class.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/ricknlis/public_html/rick/new/spm/ebay/images/inc/header.inc.php 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!

    ./ Just refers to the current directory I think. PHP will also check through the directories specified in your include_path before throwing an error. You might want to write ./inc/classfile/.

      Shire et All,

      You might want to write ./inc/classfile/.

      Can you tell me what you mean by this comment? I don't understand?

        First of all, ./ is the current directory. ../ refers to the parent directory.

        Depending on how your Web Server is setup, the ~/public_html/ directory is probably just a symlink to another file that your webserver knows how to get to. If it's a standard setup that let's users have their own directories, the requires should probably look like:

        require('./users/rick/ebay/images/MySQLHandler.class.php'); 
        require('./users/rick/ebay/images/SZPhotoGallery.class.php'); 
        require('./users/rick/ebay/images/ImageHandler.class.php'); 
        require('./users/rick/ebay/images/SZBBCodes.class.php');

        The reason why is this:

        Your webserver is probably sitting in some directory, like /var/www/ with a directory called users (/var/www/users/) In this directory, there is probably a folder called rick (/var/www/users/rick/)

        When the system admin setup your public_html file, they probably made a link from your home directory /home/rick/ (aka ~/ ) to /var/www/users/rick/ and called the link ~/public_html/.

        So, when you place files into ~/public_html/ (aka /home/rick/public_html/), they're actually being placed into /var/www/users/rick/.

        Therefore, when you specify the link to your files to be included, you want them to be relative to the /var/www/ directory, which for the webserver is just ./

        Using this, we just substitute the ~/public_html/ in the file name with ./users/rick/ and you have the path to the file that your webserver understands.

          Cirego,

          Thanks very much for the great explanation! I understand much better now.

          I haven't made the modifications yet as I am out of town on vacation but will try it as soon as I am back.

          Thanks Again!!!

            Write a Reply...