replacing ampersand with character code

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 23, 2008   (RSS)

By Deborah - October 23, 2008

Is there a way to replace a typed ampersand "&" with "&" in a texfield or textbox field? My generated web page is displaying the unescaped ampersand, and therefore doesn't pass validation.

Another CMS I used had a "search and replace" option, which allowed for such replacements.

Thanks for any help.
Deborah

Re: [Deborah] replacing ampersand with character code

By Dave - October 23, 2008

Hi Deborah,

With wysiwyg fields it should be encoded automatically. For all other fields you can use the php htmlspecialchars() function in your viewer page. You can read more about this function here: http://www.php.net/htmlspecialchars

Just add the code in red:

<?php echo htmlspecialchars($record['title']) ?>

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com