problems with htmlentities(noob question)

Thread Solved

Join Date: Sep 2009
Posts: 9
Reputation: Muazam is an unknown quantity at this point 
Solved Threads: 0
Muazam Muazam is offline Offline
Newbie Poster

problems with htmlentities(noob question)

 
0
  #1
Sep 12th, 2009
Hey, htmlentities doesn't work in this code of mine, someone know why?
Check line 11-14
Thanks.

  1. <html>
  2. <head>
  3. <title> Welcome <?php echo $_GET['name']; ?> </title>
  4. </head>
  5. <body bgcolor="<?php echo $_GET["favcolor"]; ?>"?
  6.  
  7. <h1> Welcome <?php echo $_GET['name']; ?> </h1> <br />
  8.  
  9. <?php
  10.  
  11. foreach ($_GET as $key => $verdi) {
  12. $verdi = htmlentities($verdi);
  13. $key = htmlentities($key);
  14. }
  15. echo "You live in ";
  16. echo $_GET['country'];
  17. echo ", ";
  18. echo $_GET['city'];
  19. echo " And your favorite color is ";
  20. switch ( $_GET['favcolor'] ) {
  21.  
  22. case "#ff0000";
  23. $favcolortext="Red";
  24. break;
  25.  
  26. case "#8bcdff";
  27. $favcolortext="Blue";
  28. break;
  29.  
  30.  
  31. case "#fff600";
  32. $favcolortext="Yellow";
  33. break;
  34.  
  35. case "#0cff00";
  36. $favcolortext="Green";
  37. break;
  38.  
  39. case "#a200ff";
  40. $favcolortext="Purple";
  41. break;
  42.  
  43. case "#6000ff";
  44. $favcolortext="Violet";
  45. break;
  46.  
  47. case "#ff68e1";
  48. $favcolortext="Pink";
  49. break;
  50.  
  51. case "#fbfadd";
  52. $favcolortext="Vanillia";
  53. break;
  54.  
  55. case "#730404";
  56. $favcolortext="Dark Red";
  57. break;
  58.  
  59. case "#10057a";
  60. $favcolortext="Dark Blue";
  61. break;
  62.  
  63. case "#157a05";
  64. $favcolortext="Dark Green";
  65. break;
  66.  
  67. case "#17bb9e";
  68. $favcolortext="Cyan";
  69. break;
  70.  
  71. case "#40f0fb";
  72. $favcolortext="Baby Blue";
  73. break;
  74.  
  75. }
  76.  
  77. echo "$favcolortext.";
  78.  
  79. ?>
  80. </body>
  81. </html>

Anyone wants to add me to msn? mzm_mc@hotmail.com
good coder or not, IDC. Just need some coding buddies =)
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: problems with htmlentities(noob question)

 
0
  #2
Sep 12th, 2009
You are just setting the value to a variable.

You should do something like this:
  1. foreach( $_GET as $key => $val ) {
  2. $_GET[$key] = htmlentities( $val );
  3. }
Google is your friend.

Use [code] tags.

If you have found a solution to your problem, please mark the thread as SOLVED.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 9
Reputation: Muazam is an unknown quantity at this point 
Solved Threads: 0
Muazam Muazam is offline Offline
Newbie Poster

Re: problems with htmlentities(noob question)

 
0
  #3
Sep 12th, 2009
Thanks alot, it helped.
Could you explain me one more thing, my books is telling me to do it like this:

  1. foreach ($_GET as $key => $val) {
  2. $val = htmlentities($val);
  3. if ( $key <> "name")
And it says " So on..." the books doesn't tell me more about this.
My question is what is this "<>" function called and what does it do?
or what should I search on google to get more info about this.

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: problems with htmlentities(noob question)

 
0
  #4
Sep 12th, 2009
Google is your friend.

Use [code] tags.

If you have found a solution to your problem, please mark the thread as SOLVED.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 9
Reputation: Muazam is an unknown quantity at this point 
Solved Threads: 0
Muazam Muazam is offline Offline
Newbie Poster

Re: problems with htmlentities(noob question)

 
0
  #5
Sep 12th, 2009
Thanks, solved.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC