473,386 Members | 1,846 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 fails with file in same directory

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
3 6295
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
-----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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Lars Plessmann | last post by:
I hava several php files in different folders. I tried to use relative paths. But when I call a script from another folder that has another depth, it cannot find the files that are embedded via...
3
by: Justin L. Kennedy | last post by:
I am having a problem with multiple includes. A.php require_once on two files: B.php then C.php C.php require_once on B.php again Then I get a message: Warning: main(../../B.php): failed...
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...
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...
6
by: Royan | last post by:
Ok the problem is quite hard to explain, but i'll try to keep it as simple as i can. Imagine I have the following structure of my files and folders: /root/global.inc |__/files/foo.php...
7
by: Ronald Raygun | last post by:
I have been struggling with this all afternoon and I'm, well lats just say, very pissed off ... I have a require once in a file. I am passing the fully qualified (i.e. absolute pathname) to a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.