Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PHP Coding Academy Project 1

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
NoNameWill



Joined: Mon Sep 20, 2010 11:40 pm
Posts: 18
Location: Seattle,WA

PostPosted: Mon Sep 20, 2010 11:57 pm    Post subject: PHP Coding Academy Project 1 Reply with quote

Hello,

I am getting this line in terminal when I run this script.

Code:
PHP Warning:  file_get_contents(output): failed to open stream: No such file or directory in /home/will/PHP/project1.php on line 22


There is a output file in PHP directory.

Here is what I have from following the instructions. I think I installed all the programs I need. I got them through SPM in Ubuntu 10.4.
I know I may have misinterpreted what was there. But I need some help. Thank you
Code:
<?php
function subdir_scan($dir){
    $files=scandir($dir);
    foreach($files as $file){
        if($file==".")continue;
        if($file=="..")continue;

        print "$dir/$file\n";

        if(is_dir("$dir/$file")){
            subdir_scan("$dir/$file");
        }
    }
}
chdir("..");
subdir_scan(".");
chdir("..");
ob_start();
subdir_scan(".");

$new_run=ob_get_clean();
$old_run=file_get_contents("output");

$new_array=explode("\n",$new_run);
$old_array=explode("\n",$old_run);
?>


Last edited by NoNameWill on Tue Sep 21, 2010 5:28 am; edited 1 time in total
Back to top
View user's profile Send private message
NoNameWill



Joined: Mon Sep 20, 2010 11:40 pm
Posts: 18
Location: Seattle,WA

PostPosted: Tue Sep 21, 2010 1:03 am    Post subject: Reply with quote

I have gotten to the end of project one but I am getting this now
Code:
PHP Warning:  file_put_contents(output): failed to open stream: Permission denied in /home/will/PHP/project1.php on line 36


With this script

Code:
<?php
function subdir_scan($dir){
    $files=scandir($dir);
    foreach($files as $file){
        if($file==".")continue;
        if($file=="..")continue;

        print "$dir/$file\n";

        if(is_dir("$dir/$file")){
            subdir_scan("$dir/$file");
        }
    }
}
chdir("..");
subdir_scan(".");
chdir("..");

ob_start();
subdir_scan(".");

$new_run=ob_get_clean();

if(file_exists("output")){
    $new_array=explode("\n",$new_run);
    $old_run=file_get_contents("output");   
    $old_array=explode("\n",$old_run);
   
    $differences=array_diff($new_array,$old_array);

    foreach (differences as $file){
        echo "New file detected:$file\n";
    }
}

file_put_contents("output",$new_run);
?>
Back to top
View user's profile Send private message
NoNameWill



Joined: Mon Sep 20, 2010 11:40 pm
Posts: 18
Location: Seattle,WA

PostPosted: Tue Sep 21, 2010 6:22 am    Post subject: Reply with quote

NoNameWill wrote:
I have gotten to the end of project one but I am getting this now
Code:
PHP Warning:  file_put_contents(output): failed to open stream: Permission denied in /home/will/PHP/project1.php on line 36


With this script

Code:
<?php
function subdir_scan($dir){
    $files=scandir($dir);
    foreach($files as $file){
        if($file==".")continue;
        if($file=="..")continue;

        print "$dir/$file\n";

        if(is_dir("$dir/$file")){
            subdir_scan("$dir/$file");
        }
    }
}
chdir("..");
subdir_scan(".");
chdir("..");

ob_start();
subdir_scan(".");

$new_run=ob_get_clean();

if(file_exists("output")){
    $new_array=explode("\n",$new_run);
    $old_run=file_get_contents("output");   
    $old_array=explode("\n",$old_run);
   
    $differences=array_diff($new_array,$old_array);

    foreach ($differences as $file){
        echo "New file detected:$file\n";
    }
}

file_put_contents("output",$new_run);
?>
Back to top
View user's profile Send private message
Ram
LXF regular


Joined: Thu Apr 07, 2005 10:44 pm
Posts: 1667
Location: Guisborough

PostPosted: Tue Sep 21, 2010 8:55 am    Post subject: Reply with quote

Your scanning twice - have a look at this thread!!!
_________________

lubuntu LXDE 13.10 running on AMD Phenom II*4; ASUS Crosshair III Formula MB; 4 GB Ram.....
Back to top
View user's profile Send private message MSN Messenger
NoNameWill



Joined: Mon Sep 20, 2010 11:40 pm
Posts: 18
Location: Seattle,WA

PostPosted: Tue Sep 21, 2010 4:57 pm    Post subject: Reply with quote

Now I see the error of my way. I did looked at that thread but it wasn't computing in my brain. Took a good nights rest to let it all set in.

Thank you for the help. Now off to figure out the challenge I am having in project 2. Very Happy
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
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
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast