Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dealing with special charters inputed 3

Status
Not open for further replies.

pugs421

Technical User
Joined
Nov 25, 2002
Messages
114
Location
US
When my friend enters his screen name &quot;D<O>A&quot; it is outputted on the results page as &quot;DA&quot;. What is the way around this problem?
 
Would the new code be put in when the information is displayed, or when it is entered
 
Hi,

You could do this too:

$var = &quot;D<O>A&quot;;

$search = array (&quot;'<'&quot;, &quot;'>'&quot;);
$replace = array (&quot;&amp;lt;&quot;, &quot;&amp;gt;&quot;);

$result = preg_replace ($search, $replace, $var);

Hope this helps!

relax.gif


General Exception Error:

&quot;Unknown has caused an unknown error in unknown, unknown will now unknown.&quot;
 
spyderix is absolutely right that one should use the HTML entities that correspond to the symbols that are reserved HTML characters.
It is easy to get a list of HTML entities.
 
I'd still say it's easier to use htmlspecialchars() and let the PHP guys maintain the list of reserved HTML characters for you, and worry about all the optimizations and whatnot.


(And sorry about my first post, it told me in preview that & l t ; was properly encoded to show up but then turned it into a less than anyway.)

-Rob
 
skiflyer,

There seems to be a problem with Tek-Tips regarding that. The preview shows it correctly but then when you submit from the preview it screws up.

To properly show that on here you have to type &amp;amp;lt;

relax.gif


General Exception Error:

&quot;Unknown has caused an unknown error in unknown, unknown will now unknown.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top