473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

require_once() driving me MAD ! - please HELP

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

Sep 28 '06 #1
5 1159
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.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 28 '06 #2


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 ?.

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.

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")

?

Sep 28 '06 #3
Bit Byte napisal(a):
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.
Why do you think it's a directory structure problem? You wrote that in
the ouput you get only "In script Got here Attempting to instantiate db
object ", so it stops in MySQLDatabase. Maybe there is an error.

Sep 28 '06 #4
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.
js*******@attglobal.net
==================
Sep 28 '06 #5

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
Perhaps because "/db/mysql_database.inc.php" is relative to the root of
the filesystem and not the PWD?

Sep 28 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: the wonderer | last post by:
This is an elementary question, but I've not been able to find the answer, so here goes: I am developing a site using php. I have the html header information in a file that I include in all the...
0
by: NotGiven | last post by:
Below is a code snippet I am having a hard time with. I rerquire code1.php and code 2.php. code1.php contains some variables the code needs. code2.php contains some functions I call from the...
6
by: Nik Coughin | last post by:
Say I have a script: http://www.mydomain.com/test/admin/foo.php That looks like this: <?php $baseDir = "http://" . $_SERVER . "/test"; require_once( $baseDir . '/helpers/helper.php' );
5
by: mostof | last post by:
I'm facing a problem with require_once... Instead of actually including the file i'm requiring, it just dumps it out as text... other functions are working quite well... the code look like...
3
by: Sean Quinn | last post by:
Hi, I don't know if anyone has run into similar problems, but it seems like when I use `require_once(...)' with files that contain functions I get an error indicating that it can't redeclare the...
11
by: Kimmo Laine | last post by:
I'm flipping my wig here, people. I'm using classes and making each class a file. when I'm including dependet classess, I use require_once to avoid multiple declarations - yet they happen. I put...
8
by: David T. Ashley | last post by:
Hi, Does require_once() treat "file.inc" and "subdirectory/file.inc" as the same things or different? The reason for my question is that I'd like to organize my PHP library into...
6
by: Shelly | last post by:
Here is a crazy question that has happend to me once before. I have an include file for the connection information to the server. It is like this: $hostname= "the_server_location"; $database...
3
by: Peter Wang | last post by:
Hi, all. I recently encountered a very annoying problem while using Zend Framework(ZF). We use ZF in our web application, and it works fine at the beginning, but later when concurrent...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.