Welcome! Log In Create A New Profile

Advanced

Topic 3B

Posted by joomlahost 
Announcements Last Post
Announcement : Programming Students at UNISA School of Computing 06/19/2019 02:01PM
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
Topic 3B
July 11, 2008 05:32PM
Hit counter and guest book running nicely, so Complete...
Topic 3B
July 21, 2008 01:34PM
Finished with Topic 3B

Gareth van Zyl
Re: Topic 3B
July 21, 2008 09:27PM
Also done.
Anonymous User
Re: Topic 3B
July 28, 2008 04:13PM
Done with Topic 3B.

Mamog
tongue sticking out smiley Re: Topic 3B
July 31, 2008 12:29PM
Hi


Topic 3B is complete

Thanks

Ryan Harris
Anonymous User
Re: Topic 3B
August 10, 2008 12:45PM
Task 3B-1
working nicely, whenever using the refresh button the counter is adding 1,

Task 3B-2 eye rolling smiley
problem: the page displayed in my browser is blank without any content - no directory is displaying. Like all other files I saved the directory_navigator.php in C:/xampp/htdocs/exercises. The files are all there. Unfortunately I do not find anything in the textbook regarding this topic. I tried the two scripts mentioned in sem1 forum but it does not work. When using the one from JwV, the directory appears but in a different form: The first two lines do not appear Network/ and Test/, it starts with _notes/. Therefore there are no testpages. The colorselect.html is there and is displayed when clicking the link.
Perhaps there is something wrong with my directory?

Thanks for any helpful hint.

Iris
avatar
Mac
Re: Topic 3B
August 11, 2008 07:01AM
Save the file under htdocs, and call it with http: //localhost/directory_navigator.php
What do you get now?
Anonymous User
Re: Topic 3B
August 11, 2008 04:46PM
Hi Mac,
saving it simply under htdocs and then calling it with http: //localhost/directory_navigator.php, displays a blank screen.

Using the script from JwV in the first semester:
<?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=$_GET['dir'];
if (!$dir)
$dir = ("./"winking smiley;

$dp = opendir($dir);
if(!$dp) die ("directory not opened"winking smiley;

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='$PHP_SELF?dir=$dir$item'>$item/</a></td></tr>\n";
//echo "<tr><td width='100%'><a href='$PHP_SELF$dir$item/'>$item/</a></td></tr>\n";
//echo "<tr><td width='100%'><a href='$dir$item'>$item/</a></td></tr>\n";
}
else
echo "<tr><td width='100%'><a href='$dir/$item'>$item</a></td></tr>\n ";
}
?>

shows the directory but, as mentioned before, in a different form.

I am not sure, but am I simply missing the two folders 'Network' and 'Test'?.

Thanks for your support.
Iris
avatar
Mac
Re: Topic 3B
August 14, 2008 07:11AM
It is difficult to say what is wrong from here smiling smiley
The script above is correct and should show all your files in folders under c:/xampp/htdocs.
Anonymous User
Re: Topic 3B
August 15, 2008 04:07PM
Mac,
now I have created two new folders in Windows explorer under c:/xampp/xampp/htdocs/exercises: Network and Test.
When opening directory_navigator.php in browser firefox it looks now the same as in our manual, page 40:
Just the folder /notes is still there. I cannot delete it since there is a file in there: dwsync.xml. When clicking the file in the browser display its content is displayed - to give you an idea you will see the script in here:


This XML file does not appear to have any style information associated with it. The document tree is shown below.

&#8722;
<dwsync>
<file name="firstscript.php" server="C:/Programme/xampp/htdocs/exercises/" local="128587080997361712" remote="128587080990000000"/>
<file name="colorselect.html" server="C:/Programme/xampp/htdocs/exercises/" local="126375959940000000" remote="126375959940000000"/>
<file name="cost.html" server="C:/Programme/xampp/htdocs/exercises/" local="126380154260000000" remote="126380154260000000"/>
<file name="moviesite.php" server="C:/Programme/xampp/htdocs/exercises/" local="128595702610000000" remote="128595702610000000"/>
<file name="date.php" server="C:/Programme/xampp/htdocs/exercises/" local="128594878363221416" remote="128594878360000000"/>
<file name="leapyear.php" server="C:/Programme/xampp/htdocs/exercises/" local="128594881127858216" remote="128594881120000000"/>
<file name="sorting.php" server="C:/Programme/xampp/htdocs/exercises/" local="128594883404023514" remote="128594883400000000"/>
<file name="login.php" server="C:/Programme/xampp/htdocs/exercises/" local="128595710749645216" remote="128595710740000000"/>
<file name="movie1.php" server="C:/Programme/xampp/htdocs/exercises/" local="128595705577908624" remote="128595705570000000"/>
<file name="header.php" server="C:/Programme/xampp/htdocs/exercises/" local="128595710170011744" remote="128595710170000000"/>
<file name="averagemovierate.php" server="C:/Programme/xampp/htdocs/exercises/" local="128604280480270464" remote="128604280480000000"/>
<file name="builtinmathfunct_random.php" server="C:/Programme/xampp/htdocs/exercises/" local="128604290865904272" remote="128604290860000000"/>
<file name="builtinmathfunct_numberformat.php" server="C:/Programme/xampp/htdocs/exercises/" local="128606000699224080" remote="128606000690000000"/>
<file name="builtinmathfunct_ceil.php" server="C:/Programme/xampp/htdocs/exercises/" local="128605224926255456" remote="128605224920000000"/>
<file name="builtinmathfunct_floor.php" server="C:/Programme/xampp/htdocs/exercises/" local="128605228994905888" remote="128605228990000000"/>
<file name="builtinmathfunct_max.php" server="C:/Programme/xampp/htdocs/exercises/" local="128605244165820592" remote="128605244160000000"/>
<file name="builtinmathfunct_min.php" server="C:/Programme/xampp/htdocs/exercises/" local="128605988154185200" remote="128605988150000000"/>
<file name="builtinmathfunct_rand.php" server="C:/Programme/xampp/htdocs/exercises/" local="128606006126828592" remote="128606006120000000"/>
<file name="firstprog.php" server="C:/Programme/xampp/htdocs/exercises/" local="128606010719031856" remote="128606010710000000"/>
<file name="using_if-else-arguments.php" server="C:/Programme/xampp/htdocs/exercises/" local="128606031299124576" remote="128606031290000000"/>
<file name="book.html" server="C:/Programme/xampp/htdocs/exercises/" local="128592287798337456" remote="128592287790000000"/>
<file name="arrays.php" server="C:/Programme/xampp/htdocs/exercises/" local="128606892295803696" remote="128606892290000000"/>
<file name="syntax_foreachcommand.php" server="C:/Programme/xampp/htdocs/exercises/" local="128606923600717952" remote="128606923600000000"/>
<file name="while_do-while.php" server="C:/Programme/xampp/htdocs/exercises/" local="128606930041279024" remote="128606930040000000"/>
</dwsync>

Nevertheless I guess the php script is fine, simply the content of ...htdocs/exercises is different.

Regards,
Iris
Re: Topic 3B
August 21, 2008 07:47PM
I'm slowly getting up to speed
so far so good

done this part

Torry.Msimango
Re: Topic 3B
August 23, 2008 11:32PM
Good Day,

Having a lot of fun.
Completed TOPIC 3B, and ready to move on to next Topic

Regards

Justin Leaf-Wright

www.leafydesignz.co.za

hot smiley
Re: Topic 3B
August 25, 2008 03:10PM
Finished with 3B-1 running well


only problem was the statement below ,because it reads the beginning of the file
instead of read and displaying the latest entry in the file.

What I want to know is how do you read the last file entry ,so that it displays the latest comment


<?php

//include("./guest.txt"winking smiley;
$fp = fopen ("./guest.txt","r"winking smiley;
if(!$fp) die("Cannot open ./.txt"winking smiley;
echo fread($fp, 50);
fclose($fp);
?>
Re: Topic 3B
August 26, 2008 01:24AM
I posted something and it's gone did someone delete it !
freaky!!hey?

Aint it over 'til it is
Re: Topic 3B-2
August 26, 2008 02:26PM
The script below is not working - it's for the directory handling
*
*
*
//*This script creates a directory navigation algorithm as well as the ability to view the
//contents of the files within*/

if(!$dir)
$dir = ("./"winking smiley;
$dp = opendir($dir);
if(!$dp) die ("directory not opened"winking smiley;

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 ref='$PHP_SELF?dir=$dir$item'>$item/</a></td></tr>\n";
}

else

echo"<tr><td width='100%'><a ref='$dir/$item'>$item</a></td></tr>\n";


}
?>
</table>


torry.msimango

Aint it over 'til it is
avatar
Mac
Re: Topic 3B
August 27, 2008 07:01AM
Have you read all the previous threads on this?
Re: Topic 3B
August 28, 2008 09:07AM
Did this a while ago just never got round to posting it tongue sticking out smiley.

Completed Successfully with no problems what so ever! smiling smiley
Re: Topic 3B
August 28, 2008 03:11PM
okay my script wasn't workin' 'cause I used ref instead - of - href -syntax


but then i can't access the folders :Network/ and Test/

I suspect the statement below
besides I can't grasp - what and how this - <a href='$PHP_SELF?dir=$dir$item'> -works


i.e

echo "<tr><td width='50%'><a href='$PHP_SELF?dir=$dir$item'>$item/</a></td></tr>\n";

Generates the following error message ;

Notice: Undefined variable: PHP_SELF in c:\program files\apache group\apache\htdocs\studentphp\directory_navigator.php on line 27

I tried otherscripts from the internet and they generate same message -could it be my settings for php?

Tha
Re: Topic 3B
August 28, 2008 03:14PM
okay my script wasn't workin' 'cause I used (ref) instead of - (href) - syntax


but then i can't access the folders :Network/ and Test/

I suspect the statement below
besides I can't grasp - what and how this - <a href='$PHP_SELF?dir=$dir$item'> -works


i.e

echo "<tr><td width='50%'><a href='$PHP_SELF?dir=$dir$item'>$item/</a></td></tr>\n";

Generates the following error message in my browser;

Notice: Undefined variable: PHP_SELF in c:\program files\apache group\apache\htdocs\studentphp\directory_navigator.php on line 27

I tried other scripts from the internet and they generate same message -could it be my settings for php?

Thanx before hand

torry.msimango
avatar
Mac
Re: Topic 3B
August 29, 2008 06:54AM
$PHP_SELF points to the same page, i.e. a form will post to the same page it is on. Replace with the page name e.g. this_page.php?dir=$dir$item
Re: Topic 3B
August 29, 2008 09:27PM
I have completed task 3b.

Johan Botha
Re: Topic 3B
August 29, 2008 11:08PM
I have just succeeded to do the guest book successfully. It is amazing what one can code in PHP.
Johan Botha
Re: Topic 3B
August 31, 2008 09:50PM
Good stuff!!! my directory program is working mainly as a result of the hints provided above. Thanks. Going on to lesson 4 now... :-( end of weekend.
Johan Botha
Re: Topic 3B
October 01, 2008 09:32PM
done! i ran into some problems because of a spelling mistake!!
Sorry, only registered users may post in this forum.

Click here to login