ciber Posted December 13, 2008 Share Posted December 13, 2008 I got an script I wrote to help with updating my rss feed, since I do it manually. But I have a problem, when I click submit the text in the textbox <textbox> is changing a bit, any =" is changing to =\" is there anyway of getting php to use this with out adding the \ in front of the quotation? Link to comment https://forums.phpfreaks.com/topic/136832-solved-php-keeps-adding-in-front-of-text/ Share on other sites More sharing options...
dafallenangel Posted December 13, 2008 Share Posted December 13, 2008 I got an script I wrote to help with updating my rss feed, since I do it manually. But I have a problem, when I click submit the text in the textbox <textbox> is changing a bit, any =" is changing to =\" is there anyway of getting php to use this with out adding the \ in front of the quotation? when getting your from your form (example: $data = $_POST['data'] use htmlspecialchars() as like $data = htmlspecialchars($_POST['data']; Link to comment https://forums.phpfreaks.com/topic/136832-solved-php-keeps-adding-in-front-of-text/#findComment-714604 Share on other sites More sharing options...
T Horton Posted December 13, 2008 Share Posted December 13, 2008 Hi I would personally use the stripslashes() function. <?php $str = "Submitted on \"PHPFreaks\" forum"; echo stripslashes($str); ?> Hope this helps. Tom Link to comment https://forums.phpfreaks.com/topic/136832-solved-php-keeps-adding-in-front-of-text/#findComment-714606 Share on other sites More sharing options...
DarkWater Posted December 13, 2008 Share Posted December 13, 2008 Well, just to elaborate a bit: PHP had this php.ini setting called "magic_quotes_gpc", which "magically quotes" GET, POST, and COOKIE data (hence, GPC). It was to make using this data in external programs like MySQL more secure. Turns out however, that it just causes problems. Either you could turn it off, or use a function like this: <?php function real_stripslashes($string) { if (ini_get('magic_quotes_gpc') == true) { return stripslashes($string); } return $string; } Link to comment https://forums.phpfreaks.com/topic/136832-solved-php-keeps-adding-in-front-of-text/#findComment-714608 Share on other sites More sharing options...
ciber Posted December 13, 2008 Author Share Posted December 13, 2008 I got an script I wrote to help with updating my rss feed, since I do it manually. But I have a problem, when I click submit the text in the textbox <textbox> is changing a bit, any =" is changing to =\" is there anyway of getting php to use this with out adding the \ in front of the quotation? when getting your from your form (example: $data = $_POST['data'] use htmlspecialchars() as like $data = htmlspecialchars($_POST['data']; Thanks for this, it got rid of a lot of my AMATURE coding ... Hi I would personally use the stripslashes() function. <?php $str = "Submitted on \"PHPFreaks\" forum"; echo stripslashes($str); ?> Hope this helps. Tom Also thanks to you, this fixed my \" issue! Well, just to elaborate a bit: PHP had this php.ini setting called "magic_quotes_gpc", which "magically quotes" GET, POST, and COOKIE data (hence, GPC). It was to make using this data in external programs like MySQL more secure. Turns out however, that it just causes problems. Either you could turn it off, or use a function like this: <?php function real_stripslashes($string) { if (ini_get('magic_quotes_gpc') == true) { return stripslashes($string); } return $string; } The standard striplashes seems to do the trick, but if I pick up any problems I will try this! Thanks as well! Link to comment https://forums.phpfreaks.com/topic/136832-solved-php-keeps-adding-in-front-of-text/#findComment-714620 Share on other sites More sharing options...
DarkWater Posted December 13, 2008 Share Posted December 13, 2008 The reason why just using stripslashes() is bad is because if your webhost just turns off magic_quotes_gpc, you'll be killing any legitimate slashes in the string. The function I posted makes sure magic_quotes_gpc is on before stripslash()ing. Link to comment https://forums.phpfreaks.com/topic/136832-solved-php-keeps-adding-in-front-of-text/#findComment-714627 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.