Right then..
I have an array of names called
$NAMES
with 5 names in it.
I generate a random number
$NUMBER = rand(0, 4);
I set a variable contain a random name pulled from the array
$randomNAME = $NAMES[$NUMBER];
I then create a variable containing a path to a file
$namePATH="People/$randomNAME/pictures/info.txt";
Now.. when I try to open this file (and it DOES exsist) PHP screams at me saying it DOESN'T exsist!!!
I open the file like this
$openFILE = fopen($namePATH, "r");
$personsINFO = fread($openFILE, filesize($namePATH));
fclose($openFILE);
I'm confused.
Can anyone help with this?!?!
PHP going mad.. PLEASE HELP!
Moderator: General Moderators
http://www.php.net/manual/en/function.fopen.php
Go look there.. the r command only opens a file, it does not create one in case it does not exist.
You probably want another
Go look there.. the r command only opens a file, it does not create one in case it does not exist.
You probably want another
I think "r" is ok since there is only a call to fread "(and it DOES exsist)"
try something liketo see at which part of the path it begins to complain.
try something like
Code: Select all
function checkPath($sPath)
{
$arrPath = split('/', $sPath);
$sPath = '';
for($i=0; $i!=count($arrPath); $i++)
{
$sPath .= $arrPathї$i];
print($sPath.' ');
if ( is_dir($sPath) )
print(" directory\n");
else if ( is_file($sPath) )
print(" file\n");
else
print(" failed\n");
$sPath .= '/';
}
}- string contains really what you expect?
- current working directory is right?
- the script has read/change-into permission for the paths?
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
could you show us the error?
try changing
to
try changing
Code: Select all
$namePATH="People/$randomNAME/pictures/info.txt";Code: Select all
$namePATH="People/".$randomNAME."/pictures/info.txt";