Forum Moderators: coopster

Message Too Old, No Replies

apostrophe and post value

         

samu12

12:31 pm on Sep 3, 2008 (gmt 0)

10+ Year Member



Dear All,
I am having problem while posting value particularly
(Nepal's Finest) Actually this is taken from a table and displayed on page. After selecting and posting this value for another page, I get Only Nepal instead of Nepal's Finest.

I just see the post value(Nepal only) instead of Nepal's Finest
I am sure it is because of aphostrophe, how to display that post value on another page.

Samu

penders

1:31 pm on Sep 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Have you tried just echo'ing the $_POST[] array, before it's processed in any way...?

eg.
echo '<pre>'.print_r($_POST,true).'</pre>';

dreamcatcher

2:55 pm on Sep 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



htmlspecialchars [uk3.php.net]

dc

samu12

4:30 am on Sep 4, 2008 (gmt 0)

10+ Year Member



Dear All,
thank you for your valuable time.

To: penders,

echo '<pre>'.print_r($_POST,true).'</pre>'; result of this produces:

Array
(
[1] => Nepal // instead of Nepal's Finest
[2] => New Coffee
[3] => Ethopian
[4] => Kenya AA
)

On the form where user select item and post for next page.I have the following echo code shown below.

echo "<td class='littletablerow'><input name='coffeename[$i]' type='hidden' value='$name'></td></tr>";

To: dreamcatcher,
Could give me an exaple of htmlspecialchars.

Thank you both for help
Samu

samu12

10:34 am on Sep 4, 2008 (gmt 0)

10+ Year Member



Dear All,
Thank you so much for your help. It's now solved.

Samu

penders

11:44 am on Sep 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi samu12, glad you got it sorted.

One thing that was dubious about your code, was the use of single quotes to delimit your HTML attributes in your form. But your form values contain single quotes. Unless the single quotes in your form values are encoded (perhaps with htmlspecialchars() as dreamcatcher suggested) then you could end up outputting invalid HTML and you'd only see "Nepal" in your form. (Although I would have thought you should still have seen the full "Nepal's Finest" when examining the $_POST[] array server-side when the form was first posted?)

dbarasuk

1:32 pm on Sep 4, 2008 (gmt 0)

10+ Year Member



Adding slashes to every posted array element should solve the problem, but...

can you post the full script doing that job. Any suggested idea would help you more visually, I think in that way.