473,378 Members | 1,468 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,378 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 2772
"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;
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: 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...

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.