472,993 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

problem with 'include' and 'file_exists' function

+86
i encountered this problem:
"include('inc.php')" will work problely
but "include('./inc.php') doesn't work ..
both file_exists('inc.php') or file_exists('./inc.php') didn't return
the right value.this always show "file doesn't exists'

my environment is win2003+iis+php5

how to fix it ?

sorry to my English

thanks to you.

:)

Nov 25 '06 #1
6 2755
"include('inc.php')" will work problely
>but "include('./inc.php') doesn't work ..
There are plenty of situations where this will happen. If a file
name begins with ./, it will be looked up with include_path relative
only to the current working directory, not the current script.

Are you SURE you know what the current working directory is when
the script is started?
>both file_exists('inc.php') or file_exists('./inc.php') didn't return
the right value.this always show "file doesn't exists'
include() uses include_path to search for files.
file_exists() doesn't.

>my environment is win2003+iis+php5

how to fix it ?
The fix may be to correct the "right" value. Don't think that!

Nov 25 '06 #2
+86

"Gordon Burditt д
"
thanks for your answer.
>
There are plenty of situations where this will happen. If a file
name begins with ./, it will be looked up with include_path relative
only to the current working directory, not the current script.

Are you SURE you know what the current working directory is when
the script is started?
The dicrecory is named 'test'.There's no file name like './',All files
in it ara 'info.php' and 'inc.php', if the current working directory is
'test' when i browse 'info.php'?
In this case if the two way to include is different?

include() uses include_path to search for files.
file_exists() doesn't.
I never set include_path before using win2003 and the win2000 server
run well.
>
my environment is win2003+iis+php5

how to fix it ?

The fix may be to correct the "right" value. Don't think that!
I think you can tell me how to resolve this problem..thanks :)

Nov 25 '06 #3
>There are plenty of situations where this will happen. If a file
>name begins with ./, it will be looked up with include_path relative
only to the current working directory, not the current script.

Are you SURE you know what the current working directory is when
the script is started?

The dicrecory is named 'test'.There's no file name like './',
One of the file names you passed to include() began with period slash.
The comma is punctuation in the sentence.
>All files
in it ara 'info.php' and 'inc.php', if the current working directory is
'test' when i browse 'info.php'?
If file_exists('inc.php') returns false, then the current working
directory is a directory that does NOT have an inc.php in it. On
the other hand, the directory the script is in apparently DOES have
an inc.php in it. include('inc.php') searches both places.
include('./inc.php') only searches the first one. Are you SURE you
know what the current working directory is when the script is
started?
>In this case if the two way to include is different?
Read the documentation on include(). If the file name begins with
period slash, fewer directories are searched.

include('inc.php') may search in a lot of places.
include ('./inc.php') may search in fewer places.
file_exists('inc.php') looks in ONE place.

>include() uses include_path to search for files.
file_exists() doesn't.

I never set include_path before using win2003 and the win2000 server
run well.
Are all the path names on win2000 and win2003 *EXACTLY* the same?

So what is the value of include_path? If you didn't set it, there's
a default value.
>my environment is win2003+iis+php5

how to fix it ?

The fix may be to correct the "right" value. Don't think that!

I think you can tell me how to resolve this problem..thanks :)
Print out the current working directory by calling getcwd() and echo
the value. Is it the value you thought it was?
Nov 25 '06 #4

+86 wrote:
i encountered this problem:
"include('inc.php')" will work problely
but "include('./inc.php') doesn't work ..
both file_exists('inc.php') or file_exists('./inc.php') didn't return
the right value.this always show "file doesn't exists'

my environment is win2003+iis+php5

how to fix it ?

sorry to my English

thanks to you.

:)
Can you post output of this code:
$d = dir("./");
echo "Path: " . $d->path . "\n";
while (false !== ($entry = $d->read())) {
echo $entry."\n";
}
$d->close();

It will show what you have in "./". Add it before include.

Nov 26 '06 #5
+86
Thanks to you .

I found this problem is caused by authority .

the server run well now but don't determined how did I rosolve this
problem..:(

Nov 27 '06 #6
+86 wrote:
Thanks to you .

I found this problem is caused by authority .

the server run well now but don't determined how did I rosolve this
problem..:(
You'll probably have to change the security info in your server. I
might suggest a Windows server admin newsgroup - they'll know a lot more
about how to do it.

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

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

Similar topics

0
by: Chann Becker | last post by:
My current setup: WWW Server: Windows 2000 Server, SP4 IIS5 PHP 4.3.4 File Server Windows 2000 Server, SP4
2
by: Andrew Crowe | last post by:
Hi guys, I've created this little function to check whether a user has uploaded a file with the same name as an existing file, and if so rename it to file-1.jpg, file-2.jpg etc. ...
1
by: Hinrich Specht | last post by:
Hello, I have a problem using file_exists. I want to use file_exists to dertermine if a product-image is available or not to show either the product-image or a standard-image. This is the code:...
4
by: rcb845 | last post by:
Hi everybody of the PHP community, I am using the php function "getimagesize()" to access the width/height of an image from the Web. This function should return false if image is not available....
2
by: Disco Octopus | last post by:
Hi, I am trying to upload my site to a new server, and am finding a hard time with the include() function. I am getting this... Warning: main(includes/site_auth.inc) : failed to open...
3
by: Gunnar G | last post by:
Hi. Now I have this file function A() { if (file_exists("a/foo.inc") echo "exists"; include "a/foo.inc"; ....
2
by: ELINTPimp | last post by:
Hello all, Have a really interesting problem (at least to me) with my upload_file() function. I have it working now, with a bit of a work around, but would like to know what everyone thinks in...
20
by: Bob Sanderson | last post by:
This is my code: if (file_exists($Fname)) { echo "<td>$Fname exists</td>"; } else { echo "<td>$Fname does not exist</td>"; } $Fname is the full path to the file I'm trying to verify. When I...
10
by: SoulIntruder | last post by:
Hello folks. I have a beginners question. I have such script: <?php $User = $_POST; $Password = $_POST; $Database = $_POST;
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.