Re: An "escape special characters" problem
| From: | Jason Sheets | Date: | Sat, 15 Feb 2003 19:02:15 +0000 |
| Subject: | Re: An "escape special characters" problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-135692@lists.php.net to get a copy of this message | ||
You're problem is that you are enclosing your value for your <option
tags with single quotes ('), when you fetch the value from the database
the single quote in 's ends the value='' assignment in your HTML. You
can use echo "<option value=\"$algen\">$algen"; which will solve your
single quote problem. You could also addslashes on your value and then
stripslashes when you want to operate on it, example '<option value="' .
addslashes($algen) . '">' . $algen . '">';
Jason
On Sat, 2003-02-15 at 11:58, Robert E. Harvey, M.D. wrote:
> Hi folks,
>
> I am trying to transfer data from a select list and am having problems
> with special characters stopping the transfer. The data is presented in
> a form as follows:
>
> $query = "SELECT algen FROM allist WHERE altyp = 'W' ORDER BY algen";
> $result_1 = mysql_query($query)
> or die ("Couldn't execute query.");
> /* create form containing Weed selection list */
> echo "<tr><td><form action='./calc/pad_test.php'
> method='post'>
> <select name='weed_$i'>\n";
> while ($row = mysql_fetch_array($result_1))
> {
> extract($row);
> echo "<option value='$algen'>$algen\n";
> }
>
> The problem arises when one of the strings from the table algen has an
> apostrophe in it such as "Queen Anne's Lace" or "Lamb's
> Quarters". It
> displays properly in the form. What is passed to $HTTP_POST_VARS is:
> "Queen Anne" or "Lamb".
>
> How can arrange my code to pass the entire strings to $HTTP_POST_VARS
> and not just the truncated versions?
>
> Thanks
>
> Bob
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php