Welcome! Log In Create A New Profile

Advanced

Apply your knowledge 2-1

Posted by Matete 
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
Apply your knowledge 2-1
August 21, 2007 11:29AM
Selected colors don't display. Did I do something wrong?
Re: Apply your knowledge 2-1
August 21, 2007 03:18PM
will look into it this evening. Dont stress, you will come right. could you explain what you did?
Re: Apply your knowledge 2-1
August 21, 2007 08:16PM
try putting @extract($_GET) just after the <?php

It's probably a global variables issue.
Re: Apply your knowledge 2-1
August 22, 2007 09:55AM
Hi Sandile

Thanks for your suggestion. I still can't get it right.
Re: Apply your knowledge 2-1
August 22, 2007 10:31AM
could you post here your code? or mail me,

c o m (the dot) l i a m g (the dot) m a h l i g

i am doing this due to spam...
Re: Apply your knowledge 2-1
August 22, 2007 10:33AM
Post your code so we can see where you made a mistake.
Re: Apply your knowledge 2-1
August 22, 2007 12:52PM
Hi All

Code for processing colorselect


<?php
switch ($color) {
case "yellow":
$bgcolor="#FFCC00";
break;
case "Blue":
$bgcolor= "#4682B4";
break;
case "silver":
$bgcolor="#COCOCO";
break;
case "Beige":
$bgcolor="#FFE4C4";
break;

}

echo "<html>";

echo "<head><title>Selected Background Page</title></head>";
echo "</body bgcolor='$bgcolor'>";
echo "</html>";
?>
Re: Apply your knowledge 2-1
August 22, 2007 01:16PM
I stand under correction, but dont think you can put attributes in the close body tag.

your code:

echo "<head><title>Selected Background Page</title></head>";
echo "</body bgcolor='$bgcolor'>";
echo "</html>";


try this:

echo "<head><title>Selected Background Page</title></head>";
echo "<body bgcolor=" . $bgcolor . "></body>";
echo "</html>";


the dot joins the strings together. having the single quotation marks like you do will work but it makes it easier to read by putting the dots in. this helps when you havent worked on a project for a while and they wnat a new feature added...
Re: Apply your knowledge 2-1
August 22, 2007 02:56PM
Yes, the problem is that in Matete's code (below)

echo "</body bgcolor='$bgcolor'>";

there's no opening "<body>" tag.
Re: Apply your knowledge 2-1
August 24, 2007 06:52AM
I have coded the color.php as in the Masterskills.
I then open the colorselect.html, choose a colour and click the button, i get a box asking me if i want to open/save color.php...
if i click open, it opens color.php in Notepad... if i click save, it opens the save as dialog box...
Help anyone?
Re: Apply your knowledge 2-1
August 24, 2007 08:29AM
Open the colorselect.html file in Http://localhost/... and see what happens.

Don't forget the @extract($_GET) in your php code.
Re: Apply your knowledge 2-1
August 28, 2007 02:08PM
I am done with this task!
Sjoe what a relief!
I struggled so much with it and my only problem was a semi-colon(winking smiley after
the @extract($_get)

Good old trace debugging to the rescue and booted the task!
Re: Apply your knowledge 2-1
August 28, 2007 05:25PM
i have had that problem pop up as well... very very irritating!!!! i feel your pain.

i have start using ZEND as my IDE and i can very quickly pick up on where a mistake like that occurs. its not free but i am sure there are shareware serials out there...

do what you must smiling smiley
Re: Apply your knowledge 2-1
September 12, 2007 01:44PM
Dear All

Apologies for the disappearance, I was busy with my other assignments. Thanks for your inputs. Task is now canned.
avatar
Mac
Re: Apply your knowledge 2-1
September 14, 2007 12:02PM
ernistus - if it does that, then apache is not running on your PC or apache doesn't know what to do with a php file....
Re: Apply your knowledge 2-1
September 19, 2007 09:01AM
Hi

Sorry guys times have been hectic....im having a problem with my color.php page, it use to work perfectly and now it just shows up blank....help any1

mail me if possible

riyadhsalie@woolworths.co.za

thanx
Riyadh
Re: Apply your knowledge 2-1
September 19, 2007 09:55AM
please post your code here so we can see whats going wrong...

and happy talk like a pirate day!!!
Re: Apply your knowledge 2-1
September 20, 2007 10:29AM
Hi Guys

here is my code....the page just appears blank and like i said it did work before...



<?php
@extract($_GET);
switch ($color) {
case "Yellow":
$bgcolor="#FFCC00";
break;
case "Blue":
$bgcolor="#4682B4";
break;
case "Silver":
$bgcolor="#C0C0C0";
break;
case "Beige":
$bgcolor="#FFE4C4";
break;
}
echo "<html>";
echo "<head><title>Selected Background Page</title></head>";
echo "<body bgcolor='$bgcolor'>";
echo "</body>";
echo "</html>";
?>


hope it works
Re: Apply your knowledge 2-1
September 20, 2007 05:22PM
hey riyadhsalie

this code is working perfectly...

are you by any chance going:

test.php?color=blue
or
test.php?color=Blue

because there is a difference here. note the one "Blue" has a capital and the other "blue" is in lower case.

when i ran this script with it in lower case, nothing happened. but when i ran it with a capital, i got the desired result. if you look at your code, your case statements "Blue" has a capital. if you change this to all lower case (blue), then you can use "test.php?color=blue".

if this is not the cause, then maybe try restarting your local server...

hope this helps smiling smiley

Gilham
Re: Apply your knowledge 2-1
September 21, 2007 10:29AM
Thanks Gilham

ill try it later and let you know......your help is appreciated thumbs up

Riyadh
Re: Apply your knowledge 2-1
September 21, 2007 11:54AM
no worries, let us know if you come right smiling smiley
Re: Apply your knowledge 2-1
October 09, 2007 12:00AM
Extremely late but done. Thanks to all who contributed to this thread - its been a lifesaver.
Re: Apply your knowledge 2-1
October 09, 2007 08:09AM
Better late than never!
Re: Apply your knowledge 2-1
October 09, 2007 08:18AM
Re: Apply your knowledge 2-1
October 24, 2007 08:29PM
Hi,

At first this did not work but after adding "@extract($_GET);" it was fine.
Sorry, only registered users may post in this forum.

Click here to login