474,044 Members | 62,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_patien t.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 6572
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_patien t.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(di rname(__FILE__) . '/welcome_patient .php');

- --
Edward Z. Yang GnuPG: 0x869C48DA
HTML Purifier <htmlpurifier.o rg 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/4AJYmjN21ALqqHy nEs89RbTuo4kN6A J9FeUO9
Ouvw3loD4zKUyJI eUkq1ew==
=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(di rname(__FILE__) . '/welcome_patient .php');

- --
Edward Z. Yang GnuPG: 0x869C48DA
HTML Purifier <htmlpurifier.o rg 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/4AJYmjN21ALqqHy nEs89RbTuo4kN6A J9FeUO9
Ouvw3loD4zKUyJI eUkq1ew==
=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
3334
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 require once within the included file. sample: fileA.php (in the root dir!) -----
3
2892
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 to open stream: No such file or directory in
5
2112
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 this: $forum_version = 'SMF 1.0 RC2';
3
1807
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 functions. I thought the point of the once directive was to PREVENT the system from including duplicate files (and thus attempting to redeclare the functions). It has worked elsewhere, for instance I have a database.php file, that
11
41115
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 debug_print_backtrace in the file to see how it is included, and here's the output: #0 require_once() called at #1 require_once(\eKirje.textGrid.class.php) called at #0 require_once() called at #1 require_once(\eKirje.kanava.class.php)...
8
4359
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 subdirectories, and if I accidentally have a naming collision, I'm curious how require_once() will behave. Thanks.
3
3255
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 requests goes high, we get very high cpu load. when i trace the httpd using strace, i find so much fstat64 syscalls, most of which failed, all these syscalls take more than 60% of cpu usage. After i check our php code carefully, i find
6
2511
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 |__/utils |__/logs/logger.inc When I run foo.php I get the following error:
7
1800
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 file that exists on my machine (I'm looking ath the file now). I am evaluating the pathname like this (see below) Contents of app_config.php
0
10545
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10337
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
12140
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11139
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8697
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7868
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6652
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6836
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.