baconbeastnz Posted May 28, 2008 Share Posted May 28, 2008 Hi there, Ok basically I have to correctly display messages created by users, in an environment when GPC can be both on and off My problem so far, is that when entering : hello "there" , this will output as : hello /"there/" I cannot change the echo on the other, it has to be done before the data hits the array, here is what I've tried: 'text' => '".nl2br(htmlentities($_POST["NEWMESSTEXT"]))."' The other end, is just echo($text); Any help would be really appreciated, boss is on my ass lol Link to comment https://forums.phpfreaks.com/topic/107577-magic-quotes-gpc-on-correctly-display-of-quotes/ Share on other sites More sharing options...
trq Posted May 28, 2008 Share Posted May 28, 2008 <?php if (get_magic_quotes_gpc()) { $a = array('text' => stripslashes($_POST["NEWMESSTEXT"])); } else { $a = array('text' => $_POST["NEWMESSTEXT"]); } ?> Link to comment https://forums.phpfreaks.com/topic/107577-magic-quotes-gpc-on-correctly-display-of-quotes/#findComment-551411 Share on other sites More sharing options...
baconbeastnz Posted May 28, 2008 Author Share Posted May 28, 2008 I also need to prevent special characters from getting in though: e.g <?php echo "lol" ?> and nl2br e.t.c Link to comment https://forums.phpfreaks.com/topic/107577-magic-quotes-gpc-on-correctly-display-of-quotes/#findComment-551412 Share on other sites More sharing options...
trq Posted May 28, 2008 Share Posted May 28, 2008 So add the necessary function calls. I was simply illustrating how you can determine if magic quotes gpc is switched on. Link to comment https://forums.phpfreaks.com/topic/107577-magic-quotes-gpc-on-correctly-display-of-quotes/#findComment-551413 Share on other sites More sharing options...
baconbeastnz Posted May 28, 2008 Author Share Posted May 28, 2008 MM ok I already knew that. I dont think I have illustrated my problem clearly enough.. stripslashes will work for things like: hey "there" But I also need it to display slashes properly : e.g i enter : \\\\\ and it outputs : \\\\\ , not : \\ in pseudo: if(gpc enabled) { stripslashes(text) //This is fine for : hello "there", but not for : \\\\\ ///// } else { htmlentities(text) //This is fine for : hello "there", but not for : \\\\\ ///// } Link to comment https://forums.phpfreaks.com/topic/107577-magic-quotes-gpc-on-correctly-display-of-quotes/#findComment-551414 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.