Reply to topic
PHP readdir and opendir don't work?
shmoo


Joined: 05 Oct 2005
Posts: 9
Reply with quote
So I'm trying to use the following code snippet from the PHP.net website...

Code:
<?php
// Note that !== did not exist until 4.0.0-RC2

if ($handle = opendir('/calculator')) {
    echo "Directory handle: $handle\n";
    echo "Files:\n";

    /* This is the correct way to loop over the directory. */
    while (false !== ($file = readdir($handle))) {
        echo "$file\n";
    }

    closedir($handle);
}
?>


...and I keep getting the following error message...

Warning: opendir() [function.opendir]: SAFE MODE Restriction in effect. The script whose uid is 72582 is not allowed to access / owned by uid 0 in /vservers/mywebsite/htdocs/programming/index.php on line 37

Warning: opendir(/calculator) [function.opendir]: failed to open dir: No such file or directory in /vservers/mywebsite/htdocs/programming/index.php on line 37

I'm still a bit new to PHP so can someone tell me what's going wrong?

Oh, and I'm on a shared server. I guess this is a permissions issue, but Dreamweaver doesn't seem to be letting me change permissions on the directory.

Thanks Smile
shmoo


Joined: 05 Oct 2005
Posts: 9
Reply with quote
Nevermind, I figured it out. In the line:

opendir('/calculator')

you can't have the "/" in front of calculator. It works fine if you use:

opendir('calculator')

or even

opendir('.')

if you want it to read the current directory.



I still don't know why Dreamweaver isn't letting me change permissions, however.
PHP readdir and opendir don't work?
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic