Ell20 Posted December 5, 2007 Share Posted December 5, 2007 Hi, I have a messaging system where players can message each other in the game. However if a player sends a message which contains --> there inbox dosent display correctly. The code which sends the message to the database is: $mailtext = addslashes(strip_tags($_POST['chat'])); Has anyone got any idea what I can do to stop this happening? I have tried: - $mailtext = stripslashes(strip_tags($_POST['chat'])); - $mailtext = stripslashes(trim($_POST['chat'])) But none of these combinations solved the problem. Thanks for any help Elliot Quote Link to comment Share on other sites More sharing options...
Guest Posted December 5, 2007 Share Posted December 5, 2007 Try using htmlentities($_POST['chat'], ENT_QUOTES) for when it's displayed on a page, and use mysql_real_escape_string() when you are putting it into the db. Addslashes lull developers into a false sense of security in this respect. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 5, 2007 Share Posted December 5, 2007 If you're sending the inputted text to a browser, you want to use the function htmentities() with the ENT_QUOTES option, not addslashes. Ken Quote Link to comment Share on other sites More sharing options...
Ell20 Posted December 5, 2007 Author Share Posted December 5, 2007 So something like this: $mailtext = htmentities(ENT_QUOTES($_POST['chat'])); Thanks Quote Link to comment Share on other sites More sharing options...
Guest Posted December 5, 2007 Share Posted December 5, 2007 So something like this: $mailtext = htmentities(ENT_QUOTES($_POST['chat'])); Thanks ENT_QUOTES isn't a function, its a constant. It's meant to be used as such: $text = htmlentities($_POST['chat'], ENT_QUOTES); Also, to clarify, it's htmlentities, not htmentities (the L is crucial) Quote Link to comment Share on other sites More sharing options...
Ell20 Posted December 5, 2007 Author Share Posted December 5, 2007 thanks very much for your help, solved! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.