Welcome! Log In Create A New Profile

Advanced

Task 3A and Task 3B

Posted by Truan Frames 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
avatar
Mac
Re: Task 3A and Task 3B
August 05, 2010 07:28AM
I try and highlight the pages that will help most with the assignment - but do read more!
Re: Task 3A and Task 3B
August 05, 2010 04:56PM
Completed task 3A and 3B, it took me quite a while, as i had a major project at work, and could not work on my php all the timeangry smiley
Re: Task 3A and Task 3B
August 09, 2010 12:28PM
Could have been nice to have masterskill study guide , softcopy eg. PDF version as well .. I find it easy reading from my notebook .. just started with 3A , from 2 was spending much time on prescribed book BEGINNING PHP5, APACHE and MYSQL web development handbook book ( I read the book and do the practicals before going to a topic and after the topic ) ... also spending a whole lot of time on PHPBUILDER.COM its a nice forum with examples and a big community
Re: Task 3A and Task 3B
August 09, 2010 01:04PM
Done with these ....it was a bit more challenging ....but i made it through it ! smile
Re: Task 3A and Task 3B
August 09, 2010 01:34PM
Just done with Task 3. Had a problem with getting my variables from one forum to another. But figured that out. For example: The Guestbook one. In the form guestbookform.php you have the Firstname and lastname input plus the Comments. And in guestbook.php where it has to write the firstname, lastname and comments to the text document, I kept getting the parse error variables $firstname, $lastname and $comments does not exist. Reading through a few forums came across codding that helped a lot. Just under <?php I put this code in:

$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$comments = $_POST['comments'];

Problem solved. So my opinion is if you struggling with something forums is very helpful!!!!
Re: Task 3A and Task 3B
August 09, 2010 02:58PM
I'm done, but it took me a while to work around, visiting old forums does help.
Re: Task 3A and Task 3B
August 09, 2010 03:03PM
I completed the taks though I had a tought time, old forums do help. I managed to sail through.
Re: Task 3A and Task 3B
August 11, 2010 08:55PM
Now that was really cool smile
No hassles with the hit counter and the guestbook ... and it was easier than I thought it would be. Am really chuffed that it works and looks good !!
Still having an issue with putting my semi-colons and quotes in the right places but getting there. Hopefully 3B-2 is as smooth.
avatar Re: Task 3A and Task 3B
August 14, 2010 02:34PM
I'm really struggling with Task 3B-2.

Searched old forums but can't find the solution.

Everything else works but can't access the Test and Network folders.

Please help.

Here's the code:
Language: PHP
<?php /*This script creates a directory navigation script that allows users to view the contents of a directory as well as the contents of the files within the directory.*/ $dir = NULL; if(!$dir) $dir = ("./"); $dp = opendir($dir); echo "<table border=';0'; width =';100%'; cellspacing=';0'; cellpadding=';0';>\n"; while($filenames[] = readdir($dp)); sort($filenames); for($i = 0; $i < count($filenames); $i++) { $item = $filenames[$i];   if(is_dir($item)) { if($item != ';.'; && $item != ';..';) echo "<tr><td width=';100%';><a href=';".$_SERVER[';PHP_SELF';]."?dir=".$dir.$item."';>".$item."/</a></td></tr>\n"; } else echo "<tr><td width=';100%';><a href=';$dir/$item';>$item</a></td></tr>\n"; }   echo "</table>"; ?>

>>>
The One that owns The Technology rulez the world!
Re: Task 3A and Task 3B
August 14, 2010 05:00PM
add $dir=$_GET['dir']; at the top.
avatar
Mac
Re: Task 3A and Task 3B
August 15, 2010 01:29PM
And hopefully you will know the reason for having to add this....!
avatar Re: Task 3A and Task 3B
August 19, 2010 11:00AM
Hi guys,

I'm still struggling with task 3B-2. Truan Frames gave me advice as to add $dir=$GET_['dir'] at the top of the code. This works but I get an error message in the browser: Notice: Undefined index: dir in ....

Here's my code:

Language: PHP
<?php /*This script creates a directory navigation script that allows users to view the contents of a directory as well as the contents of the files within the directory.*/ $dir = NULL; $dir = $_GET[';dir';]; if(!$dir) $dir = ("./"); $dp = opendir($dir); echo "<table border=';0'; width =';100%'; cellspacing=';0'; cellpadding=';0';>\n"; while($filenames[] = readdir($dp)); sort($filenames); for($i = 0; $i < count($filenames); $i++) { $item = $filenames[$i];   if(is_dir($item)) { if($item != ';.'; && $item != ';..';) echo "<tr><td width=';100%';><a href=';".$_SERVER[';PHP_SELF';]."?dir=".$dir.$item."';>".$item."/</a></td></tr>\n"; } else echo "<tr><td width=';100%';><a href=';$dir/$item';>$item</a></td></tr>\n"; }   echo "</table>"; ?>


I think I add this because I want the same script to run again based on another folder.

Please let me know where to add this piece of code ($dir=$GET_['dir']) so that I don't get this error message.
Re: Task 3A and Task 3B
August 19, 2010 11:11AM
what are you trying to accomplish with this code?

Language: PHP
$dir = NULL;
avatar
Mac
Re: Task 3A and Task 3B
August 19, 2010 05:05PM
> Truan Frames gave me advice as to add $dir=$GET_['dir'] at the top of the code.

Do you understand why? It's in the handbook... smiling smiley And, asxmgcoyi rightly asks, what ARE you trying to achieve with that? The code is not necessarily correct, but let us assume for a moment it is. Hence you are destroying the variable you want to use in the next line????
Re: Task 3A and Task 3B
August 20, 2010 10:18AM
Just finished this task, getting the concept goes beyond the time put on to complete the task .... to the next task things starting to make more sense with the practical nature of them
avatar Re: Task 3A and Task 3B
August 20, 2010 01:43PM
I added $dir = NULL because I was getting an error saying that $dir is an undefined variable.

I added $dir = $_GET['dir'] at the top and it works, except I'm getting an error - Notice: Undefined index: dir in C:\wamp\www\StudentPHP\directory_navigator.php on line 5.

I'm no longer getting the "undefined variable" error anymore. The "Undefined index: dir" is the only error now.

I think I understand why we add $dir = $_GET['dir']:

//We want to see if $dir exists or not because we cannot say "if it doesn't exist" without checking if it exists or not.


About the error...it could be because I'm running the latest Wamp and not Xaamp? confused smiley

Also, it seems that xmgcoyi also struggled with this task. I would like to know how other guys did it with such ease. Did u just look in the old forums and just add and that was it? Or did u try to understand? Just a question. confused smiley

Here's my code:

Language: PHP
<?php /*This script creates a directory navigation script that allows users to view the contents of a directory as well as the contents of the files within the directory.*/   //We want to see if it exists or not because we cannot say "if it doesn';t exist" without checking if it exists or not. $dir = $_GET[';dir';]; if (!$dir) $dir = ("./"); $dp = opendir($dir); echo "<table border=';0'; width=';100%'; cellspacing=';0'; cellpadding=';0';>\n"; while($filenames[] = readdir($dp)); sort($filenames); for ($i = 0; $i < count($filenames); $i++){ $item = $filenames[$i]; if (is_dir($item)) { if($item != ';.'; && $item != ';..';) echo "<tr><td width =';100%';><a href=';".$_SERVER[';PHP_SELF';]."?dir=".$dir.$item."';>".$item."/</a></td></tr>\n"; } else {echo "<tr><td width=';100%';><a href=';".$dir."/".$item."';>{$item}</a></td></tr>\n"; } } echo "</table>"; ?>
avatar
Mac
Re: Task 3A and Task 3B
August 23, 2010 07:14AM
avatar
Mac
Re: Task 3A and Task 3B
August 24, 2010 06:43AM
That means you place it all in a conditional statement

Language: PHP
if(isset($_GET[';dir';])) { $dir = ("./"); $dp = opendir($dir); ......... }   //or     if(!isset( $_GET[dir])) { $_GET[dir]=""; }   //or   echo (isset($_GET[';dir';])) ? $_GET[';dir';] : "";   // which is another way of say if/else - the part after the ? is the 1st bracket code and the part after the : is the else part.
Re: Task 3A and Task 3B
August 24, 2010 11:55PM
the code that theSynthesizer posted runs on my PC. I am running Xampp control panel 2.3 on Windows Vista 32bit.The browser is G Chrome 5.0 if it makes a difference but it shouldn'tspinning smiley sticking its tongue out
avatar
Mac
Re: Task 3A and Task 3B
August 25, 2010 07:12AM
A browser just displays the results of the parsed code, which is handled by Apache, so it has no influence. More likely different server and php configurations - usually error-reporting settings (why it is not standard I won't know). Having said that, the suggestions i made here above is a good standard to follow wether your receive the error message or not.
avatar Re: Task 3A and Task 3B
August 25, 2010 10:34AM
yepeeee!!!!!!

it works and no notices!!!!!!!!!!! grinning smiley

Thanks mac and xmgcoyi!!! smileys with beer

>>>
The One that owns The Technology rulez the world!
Re: Task 3A and Task 3B
September 02, 2010 03:25PM
Finished with 3A, 3B.
I struggled a bit with 3B, then i found out that " and ' work very differently in PHP.
Re: Task 3A and Task 3B
September 05, 2010 02:26PM
Successfully completed, no hassles. Chapter 3 really got my attention! It introduces some interesting capabilities of PHP! Loving it & am now really into it! Peter Fortune
Re: Task 3A and Task 3B
September 09, 2010 08:27AM
Done with 3A and B. Prescribed textbook is excellent.
Re: Task 3A and Task 3B
September 13, 2010 11:53AM
Successfully completed!
Re: Task 3A and Task 3B
September 28, 2010 01:26PM
After a 2 weeks of military operations and presentations .... just finnished both this task put in a week long PHP leave to catch up
Anonymous User
Re: Task 3A and Task 3B
October 09, 2010 03:25PM
lot of typo's work
Sorry, only registered users may post in this forum.

Click here to login