943,840 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 528
  • PHP RSS
Sep 12th, 2009
0

problems with htmlentities(noob question)

Expand Post »
Hey, htmlentities doesn't work in this code of mine, someone know why?
Check line 11-14
Thanks.

PHP Syntax (Toggle Plain Text)
  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 =)
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
Muazam is offline Offline
29 posts
since Sep 2009
Sep 12th, 2009
0

Re: problems with htmlentities(noob question)

You are just setting the value to a variable.

You should do something like this:
PHP Syntax (Toggle Plain Text)
  1. foreach( $_GET as $key => $val ) {
  2. $_GET[$key] = htmlentities( $val );
  3. }
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Sep 12th, 2009
0

Re: problems with htmlentities(noob question)

Thanks alot, it helped.
Could you explain me one more thing, my books is telling me to do it like this:

PHP Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 1
Light Poster
Muazam is offline Offline
29 posts
since Sep 2009
Sep 12th, 2009
0

Re: problems with htmlentities(noob question)

Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Sep 12th, 2009
0

Re: problems with htmlentities(noob question)

Thanks, solved.
Reputation Points: 10
Solved Threads: 1
Light Poster
Muazam is offline Offline
29 posts
since Sep 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: A warning problem
Next Thread in PHP Forum Timeline: How do I install Sablotron with PHP?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC