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
Task 3A and Task 3B
July 14, 2010 12:38PM
Just completed all task lesson 3

i had a bit of trouble with the apply your knowledge and the counter but both turned out to be typo's...
avatar
Mac
Re: Task 3A and Task 3B
July 14, 2010 01:15PM
99% of time it is typo's smiling smiley It can drive you up the wall!
Re: Task 3A and Task 3B
July 16, 2010 03:34PM
I have completed Task 3A and 3B

-Nicholas Karlsen
Re: Task 3A and Task 3B
July 20, 2010 02:49PM
All tasks in lesson 3 complete.

Things are looking interesting at this point.

This course has definitely got my attention.
avatar
Mac
Re: Task 3A and Task 3B
July 20, 2010 04:54PM
MicheleC Wrote:
-------------------------------------------------------
> This course has definitely got my attention.

grinning smiley
avatar Re: Task 3A and Task 3B
July 23, 2010 03:22PM
Hmmm...

Task 3A-1 nearly got me but i figured it out in a sec or so.

The HTML comment "<!--INSERT CODE HERE-->" was still there from the original document.

I realised that I was in a PHP environment so I used the PHP commenting syntax "//" to comment it out.

Sneaky computer - what will happen when it reaches a.i. smile

PS: Why the heck would I want to remove the </body> and </html> tags! smile

As someone in one of the other posts wrote:

Peace, Love and PHP smileys with beer
Re: Task 3A and Task 3B
July 24, 2010 01:21PM
Finally completed tasks 3A and 3B.

Took me a while to figure out what's what & did a LOT of digging in the forums and finally found some semi-right code which I just cleaned up!
Re: Task 3A and Task 3B
July 27, 2010 08:41PM
I'm also done with all of these tasks.

I had a problem with a typo as well, i struggled for an hour and a half with Task 3B-2, before i finally figured out i'm missing a $ in one of my variables, just lovely.. I always wondered how to create a hit counter and a guest book, didn't know it was that simple, makes alot of sense. Also, i think the include statement is priceless.

Happy hunting.
Re: Task 3A and Task 3B
July 28, 2010 03:59PM
angry smiley
I have tried everything! I cannot get the programme to enter the Test directory and then view the testpages.html. I have screened my code for at least 10 times! I still cannot find the problem. please help
Re: Task 3A and Task 3B
July 28, 2010 04:10PM
post the code
Re: Task 3A and Task 3B
July 28, 2010 04:27PM
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 */   if(!$dir) $dir = ("./"); $dp = opendir($dir); echo "$_SERVER[PHP_SELF]<br/>"; echo "<table border=';0'; cellspacng=';0'; width=';100%'; 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"; } } ?> </table>
Re: Task 3A and Task 3B
July 28, 2010 05:07PM
Re: Task 3A and Task 3B
July 28, 2010 07:01PM
confused smiley

the folder and the files is in the directory of htdocs. this is what i get in the url:

Language: HTML
http://localhost/xolaniphp/directory_navigator.php?dir=./Test

if I click on the test folder.
avatar
Mac
Re: Task 3A and Task 3B
July 29, 2010 10:14AM
Looking at the code just 10 times is not much - you should be lookong at it 100 times (and will in the future - that is programming for you!)

http://osprey.unisa.ac.za/phorum/read.php?215,75084
avatar Re: Task 3A and Task 3B
July 29, 2010 12:06PM
when they say that readdir() reads entries from the chosen directory:

1) Does it mean it reads the names of other directories in the same directory

OR

2) Does it mean it reads the names of the sub-directories of the chosen directory.

confused smiley

I see the result of the code but i need to "get" it!

Hope my question makes sense. eye rolling smiley

>>>
The One that owns The Technology rulez the world!
avatar Re: Task 3A and Task 3B
July 29, 2010 01:34PM
Hi everyone,

can someone plz tell me what's wrong with this line of code:

Language: PHP
echo "<tr><td width =';100%';><a href=\"$_SERVER[';PHP_SELF';]?dir=\".$dir$item.\"\">$item/</a></td></tr>\n";


the complete code is:

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.*/   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"; } } ?>

>>>
The One that owns The Technology rulez the world!
avatar
Mac
Re: Task 3A and Task 3B
July 30, 2010 07:06AM
theSinthesizer Wrote:
-------------------------------------------------------
> when they say that readdir() reads entries from
> the chosen directory:
>
> 1) Does it mean it reads the names of other
> directories in the same directory
>
> OR
>
> 2) Does it mean it reads the names of the
> sub-directories of the chosen directory.
>
> confused smiley
>

It depends what the specified top level directory is. If there are other directories in a specified directory, then these other directories must be subdirectories of the specified directory....
exept when you are at the very top level (normally called root), which is not really a directory.
avatar
Mac
Re: Task 3A and Task 3B
July 30, 2010 07:17AM
theSinthesizer Wrote:
-------------------------------------------------------
> Hi everyone,
>
> can someone plz tell me what's wrong with this
> line of code:
>
Eveything is wrong with it, especially this part - dir=\".$dir$item.\"\">$item

\ is used to escape all extra " (echo uses ".....";, therefore you need to escape the rest that is used inside the echo statement)
Here there is an attempt at concatenation (using the . to join two strings) as well as an attempt to escape the " which is also used when concatening strings - but not with an \. So either concatenate , or escape.
Re: Task 3A and Task 3B
July 30, 2010 11:01AM
Please check my code above, Please tell me whether it is similar to yours or what i have done wrong!!! I am going crazy now! I looked on the book and the internet nothing helps!sad smiley
Re: Task 3A and Task 3B
July 30, 2010 11:28AM
i have went to several tutorials on the web and my code matches exactly. is there anyone willing to test my code on their machine and see whether it works on their machine? please guys i need to move on with these exercises
Re: Task 3A and Task 3B
July 30, 2010 12:54PM
mac

i was testing xmgcoyi coding on my pc and came across something perculiar, when i left his coding as is i came up with the same as he did it ran but would not enter the test directory but when i added an extra . to the dir variable like this $dir = ("../"winking smiley; it ran, and i ended up in the parent directory and it went into test and ran the pages without a problem, can you explain why this happens?
Re: Task 3A and Task 3B
July 31, 2010 11:33AM
i tried that, but it does not the desired effect. It looks like FTP instead of the way the book looks like!confused smiley
avatar
Mac
Re: Task 3A and Task 3B
August 02, 2010 07:20AM
the more .'s you add, the higher up it takes in you up in your directories.

Have you looked at previous forums? The answer is there. In fact, I have posted a link to a previous forum were the answer is provided here above. I want you to figure it out, so read through that post.
Re: Task 3A and Task 3B
August 02, 2010 03:24PM
mac

i know that the more ./ you add the higher up it goes in the directory, i was wondering why when you start in a higher directory i could access the test folder but when starting in the current directory it would not work?
avatar
Mac
Re: Task 3A and Task 3B
August 03, 2010 07:09AM
Because the code is not correct smiling smiley Seriously, I would assume that it has to do something with the readir function. That is a built-in function, and it will only work as supposed when the code is correct.
Re: Task 3A and Task 3B
August 03, 2010 09:50AM
mac

ha ha, thanks it was just bugging me.
Re: Task 3A and Task 3B
August 04, 2010 11:09AM
Done!!! After weeks of frustration!!!!!

This has got me thinking and I have a few questions
  • The guys who finish first how did you know about the first line of code ( I mean I had a suspicion at first but I never thought it could be the problem)?
  • Mac should I treat ALL CODE in masterskill handbook as incorrect until I correct it?
  • How do I use the book in conjuction with the masterskill? Lesson 1 = chapter ?? on the book(I tried tut 101 in vain)...
Re: Task 3A and Task 3B
August 04, 2010 03:21PM
after a while of turning around in circles i ended up going to the previous years forums, somebody has usually had the same problem as you before.
avatar
Mac
Re: Task 3A and Task 3B
August 04, 2010 04:45PM
> [*] Mac should I treat ALL CODE in masterskill
> handbook as incorrect until I correct it?
The code is correct - except that you need to figure out how to capture variables between pages. Should not take too long though, and then to remember this throughout the rest of the exercises.... smiling smiley
> [*] How do I use the book in conjuction with the
> masterskill? Lesson 1 = chapter ?? on the book(I
> tried tut 101 in vain)...
>
I am getting worried here! Page 7 of the tut letter...???
Re: Task 3A and Task 3B
August 04, 2010 10:09PM
the reason for the question is that the tut shows not more than 4 pages of the book should be read for a lesson! But i see from lesson 4 chapter 8.

Thanks Mac i just needed to make suresmiling smiley
Sorry, only registered users may post in this forum.

Click here to login