Re: require_once() driving me MAD ! - please HELP



Bit Byte wrote:


Jerry Stuckle wrote:

Bit Byte wrote:

I have written a number of PHP include files. I have carefully partitioned them into logical folders - based on functionality. My directory structure looks something like this:

$(rootdir)/includes/
$(rootdir)/includes/patterns
$(rootdir)/includes/core/db
$(rootdir)/includes/core/utils
$(rootdir)/includes/core/logger
...

etc.

Each folder contains one or more files. I wrote the following script to test my db classes:

<?php
echo "In script\n" ;
include ("/db/mysql_database.inc.php");
echo "Got here\n" ;

try
{
echo "Attempting to instantiate db object\n" ;
$m_dbconnection = new MySQLDatabase();
echo "Object created succesfully\n" ;
}
catch (Exception $e)
{
echo "Exception caught : " . $e->getMessage() . "\n" ;
}
?>

Output: "In script Got here Attempting to instantiate db object "

I cannot, for the life of me, work out wtf is wrong iwth the script, and why I can't seem to use my directory structure. The above script is being run from $(rootdir). $(rootdir) is in folder htdocs under Apache.

Additional Info:
----------------------
PHP Version: PHP5
Web Server: Apache 2.0
OS: Windows 2K




include ("/db/mysql_database.inc.php");

This would be an absolute path to the file system, not a relative path in your web server. If you were displaying errors you would have one indicating the file was not found.


Hi Jerry, not sure I follow your response (i.e. its rather ambigious). Did you mean to say that my include directive SHOULD (you wrote WOULD) be an absolute path to the file system ?.


The one you gave is an absolute path to the file system. Do you actually have a /db directory on your file system?

To avoid going round in circles over the syntax of should and would, could you please correct the include statement - so that the new line is the correct statement that will work.


If /db is relative to your document root, the following works with any server - Windows or Linux:

include ($_SERVER['DOCUMENT_ROOT'] . '/db/mysql_database.inc.php');

$_SERVER['DOCUMENT_ROOT'] gives the absolute path to your web site on either system.

For example, should I write:

include ("c:\my_full_path\db\mysql_database.inc.php"); //note windows path notation OR
include ("c:/my_full_path/db/mysql_database.inc.php"); OR
include ("../path_relative_from_THIS_file_to_include_file/db/mysql_database.inc.php"); OR
include ("..\path_relative_from_THIS_file_to_include_file\db\mysql_database.inc.php")


?



--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: require_once() driving me MAD ! - please HELP
    ... Each folder contains one or more files. ... echo "In script\n"; ... I cannot, for the life of me, work out wtf is wrong iwth the script, and why I can't seem to use my directory structure. ... Did you mean to say that my include directive SHOULD be an absolute path to the file system ?. ...
    (comp.lang.php)
  • Re: Directory Size problem
    ... I've shutdown all potential ... sevices that could possibly be using teh directory e.g sendmail, ... If we could, we would put this directory structure on a separate file system since it was faster to unmount it, format it and remount it than it was to rm -rf the directory structure. ...
    (Fedora)
  • Re: Directory Size problem
    ... I've shutdown all potential ... sevices that could possibly be using teh directory e.g sendmail, ... put this directory structure on a separate file system since it was ...
    (Fedora)
  • Re: Best way to store a large number of files?
    ... Meta data desribing the images will be stored in a database but ... on the file system with a reference stored in the database. ... of giving each image a 10-digit number and placing the image in a directory structure such as this ~ ...
    (comp.lang.java.programmer)
  • Best way to store a large number of files?
    ... Meta data desribing the images will be stored in a database but ... on the file system with a reference stored in the database. ... in a directory structure such as this ~ ...
    (comp.lang.java.programmer)