By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,557 Members | 1,406 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,557 IT Pros & Developers. It's quick & easy.

Displaying " in a form text box

P: n/a
Hi all ive added a form to a script using php and the form is to hold
sizes of a product which means the client needs to be able to use " to
denote inches. However when this is entered and the form submitted it
makes it into the table and then displays as text on the page but not
inside the form as its value. Is there a way around this?

Ive tried replacing " with ' and a ' together but can't get this to
work in the str_replace funtion example: str_replace('"', '''',
$string); and help would be greatly appeciated!

Kind regards

Marc

Jun 26 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Rik
monomaniac21 wrote:
Hi all ive added a form to a script using php and the form is to hold
sizes of a product which means the client needs to be able to use " to
denote inches. However when this is entered and the form submitted it
makes it into the table and then displays as text on the page but not
inside the form as its value. Is there a way around this?
htmlspecialchars($string);

Among others, it will replace '"' with '"'
Ive tried replacing " with ' and a ' together but can't get this to
work in the str_replace funtion example: str_replace('"', '''',
$string); and help would be greatly appeciated!

Ugly solution, but here;s how it would work:
str_replace('"', '\'\'',$string);
or
str_replace('"', "''",$string);

Grtz,
--
Rik Wasmus
Jun 26 '06 #2

P: n/a
Message-ID: <e1***************************@news1.tudelft.nl> from Rik
contained the following:
htmlspecialchars($string);

Among others, it will replace '"' with '&quot;'


Don't you need to do this?

htmlspecialchars($string, ENT_QUOTES);

--
Regards,

Geoff Berrow
Jun 26 '06 #3

P: n/a
Rik
Geoff Berrow wrote:
Message-ID: <e1***************************@news1.tudelft.nl> from Rik
contained the following:
htmlspecialchars($string);

Among others, it will replace '"' with '&quot;'


Don't you need to do this?

htmlspecialchars($string, ENT_QUOTES);


Default is ENT_COMPAT, which only translates double quotes, which would be
sufficient in this particular case. ENT_QUOTES will also translate the
single quotes, which is not strictly neccessary here, but might be a good
idea indeed.

Grtz,
--
Rik Wasmus
Jun 26 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.