By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,994 Members | 2,073 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,994 IT Pros & Developers. It's quick & easy.

require_once fails with file in same directory

P: n/a
Has anyone come across this problem with require_once?

I was working on my local machine with apache and have included a file
like this:

require_once "welcome_patient.php";

Works fine, the file that "requires" this is in the same directory

/
/sections <- both file and required file in here
/images

On our live server, the require_once fails every time, include path
says: include_path='.:./includes:/usr/share/pear:'

Strange thing is, if I change require_once to include_once it works fine
but I'd prefer the script to fall over if it doesn't find the include.

Thanks in advance.

PS. Only other difference between servers is my local machine is Windows
and live is Linux, but I checked the include path delimiters were correct.

May 22 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Tyno Gendo wrote:
Has anyone come across this problem with require_once?

I was working on my local machine with apache and have included a file
like this:

require_once "welcome_patient.php";

Works fine, the file that "requires" this is in the same directory

/
/sections <- both file and required file in here
/images

On our live server, the require_once fails every time, include path
says: include_path='.:./includes:/usr/share/pear:'

Strange thing is, if I change require_once to include_once it works fine
but I'd prefer the script to fall over if it doesn't find the include.

Thanks in advance.

PS. Only other difference between servers is my local machine is Windows
and live is Linux, but I checked the include path delimiters were correct.
what happens when you have
require_once "./welcome_patient.php";
May 22 '07 #2

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tyno Gendo wrote:
Has anyone come across this problem with require_once? [snip]
It's quite puzzling. The PHP manual states that are identical in every
way, so I'm inclined to distrust your testimony.

Some possible fixes:
- - Change the ./includes entry to a fully qualified absolute path

Some definitely will work fixes:
- - Use require_once(dirname(__FILE__) . '/welcome_patient.php');

- --
Edward Z. Yang GnuPG: 0x869C48DA
HTML Purifier <htmlpurifier.org Anti-XSS HTML Filter
[[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD4DBQFGU0F0qTO+fYacSNoRAu/4AJYmjN21ALqqHynEs89RbTuo4kN6AJ9FeUO9
Ouvw3loD4zKUyJIeUkq1ew==
=oTjI
-----END PGP SIGNATURE-----
May 22 '07 #3

P: n/a
Edward Z. Yang wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tyno Gendo wrote:
>Has anyone come across this problem with require_once? [snip]

It's quite puzzling. The PHP manual states that are identical in every
way, so I'm inclined to distrust your testimony.

Some possible fixes:
- - Change the ./includes entry to a fully qualified absolute path

Some definitely will work fixes:
- - Use require_once(dirname(__FILE__) . '/welcome_patient.php');

- --
Edward Z. Yang GnuPG: 0x869C48DA
HTML Purifier <htmlpurifier.org Anti-XSS HTML Filter
[[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD4DBQFGU0F0qTO+fYacSNoRAu/4AJYmjN21ALqqHynEs89RbTuo4kN6AJ9FeUO9
Ouvw3loD4zKUyJIeUkq1ew==
=oTjI
-----END PGP SIGNATURE-----
you were correct to distrust me, i lied and include_once wasn't actually
working either LOL, if i did this it worked on the live server and on
the internal machine... in the end the following seemed fine

require_once getcwd() . '/sections/template.tpl';
May 23 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.