Jump to content

[SOLVED] Permission denied... on localhost.


blueman378

Recommended Posts

hi guys, im using a windows machine xp.

 

im trying to write some code to include all files from a directory.

 

so i have my index.php

i also have a directory called plugins.

 

heres my code:

<?php if ($handle = opendir('plugins/')) {
echo "<!--included plugins:-->";
    while (false !== ($file = readdir($handle))) {
    	if($file != "." && $file != "..")
        echo "<!--$file-->\n";
        include_once("plugins/$file");
?>
    }

 

but im getting:

Warning: include_once(plugins\.) [function.include-once]: failed to open stream: Permission denied in C:\wamp\www\Smarty Forum\index.php on line 76

Warning: include_once() [function.include]: Failed opening 'plugins\.' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\Smarty Forum\index.php on line 76

Warning: include_once(plugins\..) [function.include-once]: failed to open stream: Permission denied in C:\wamp\www\Smarty Forum\index.php on line 76

Warning: include_once() [function.include]: Failed opening 'plugins\..' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\Smarty Forum\index.php on line 76

 

any ideas?

Link to comment
https://forums.phpfreaks.com/topic/130144-solved-permission-denied-on-localhost/
Share on other sites

You're trying to include . (because your if statement doesn't have brackets) which is causing the problem.

 

       if($file != "." && $file != "..")
        echo "<!--$file-->\n";
        include_once("plugins/$file");

 

should be

 

       if($file != "." && $file != "..") {
        echo "<!--$file-->\n";
        include_once("plugins/$file");
       }

it's really personal preference. I've seen professional programmers do

if(1 < i && i < 5) {

if(i > 1 && i < 5) {

if(null === ($something)) {

etc..

 

it's another one of those things like variable and method naming, as long as you're consistent there's nothing wrong with doing it either way.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.