htmlspecialchars() problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Running php 4.3.6 on winxp machine
I have following code:
Restaurants  <select size='1' name='restaurants'>
    while ( $row = mysql_fetch_array($restaurant)){
          $opt = "<option  value = '" .     $row["title"] . "'>" .
         . "</option>";
           $opt = htmlspecialchars($opt, ENT_QUOTES);
          echo "$opt";

echo "$opt";
the last echo returns: (for debugging purposes)
<option value = 'The Oven'>The Oven</option>
which is what i'm trying to produce
however the dropdownbox is not populated with anything
am i a moron. there has got to be something simple here that is wrong
that i don't see.

Re: htmlspecialchars() problem

On 29 Nov 2004 11:39:43 -0800, (brianj) wrote:

Quoted text here. Click to load it

 No, it would have produced:

&lt;option value= = 'The Oven'&gt;The Oven&lt;option&gt;
 You've HTML-encoded the entire tag. You only want to encode the value.

 Something like:

Restaurants <select size='1' name='restaurants'>
while ($row = mysql_fetch_array($restaurant))
    printf("<option value='%s'>%s</option>\n",

< Space: disk usage analysis tool

Site Timeline