vinpkl Posted November 4, 2012 Share Posted November 4, 2012 hi all We use mysql_real_escape_string when magic_quotes_gpc is On or when magic_quotes_gpc is off vineet Quote Link to comment https://forums.phpfreaks.com/topic/270270-mysql_real_escape_string-magic-quotes/ Share on other sites More sharing options...
kicken Posted November 4, 2012 Share Posted November 4, 2012 You use it regardless of the magic quotes setting. However if magic quotes=on then you need to run your request data through stripslashes before hand. Quote Link to comment https://forums.phpfreaks.com/topic/270270-mysql_real_escape_string-magic-quotes/#findComment-1390080 Share on other sites More sharing options...
vinpkl Posted November 4, 2012 Author Share Posted November 4, 2012 hi So I will have to convert all my present code <? $name = mysql_real_escape_string($_POST['name']); $email = mysql_real_escape_string($_POST['email']); $detail = mysql_real_escape_string($_POST['detail']); ?> to like the below code on every page <? if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { $name = stripslashes($_POST['name']); $email = stripslashes($_POST['email']); $detail = stripslashes($_POST['detail']); } $name = mysql_real_escape_string($_POST['name']); $email = mysql_real_escape_string($_POST['email']); $detail = mysql_real_escape_string($_POST['detail']); ?> vineet Quote Link to comment https://forums.phpfreaks.com/topic/270270-mysql_real_escape_string-magic-quotes/#findComment-1390084 Share on other sites More sharing options...
vinpkl Posted November 4, 2012 Author Share Posted November 4, 2012 hi how can i disable magic quotes. i m on shared hosting vineet Quote Link to comment https://forums.phpfreaks.com/topic/270270-mysql_real_escape_string-magic-quotes/#findComment-1390085 Share on other sites More sharing options...
Christian F. Posted November 4, 2012 Share Posted November 4, 2012 Best way, if you don't know whether or not you've got access to php.ini is to ask the host. If that doesn't help, then might be able to set the INI variables with .htaccess. Quote Link to comment https://forums.phpfreaks.com/topic/270270-mysql_real_escape_string-magic-quotes/#findComment-1390165 Share on other sites More sharing options...
MMDE Posted November 4, 2012 Share Posted November 4, 2012 You can also check the php.ini settings by using this function: http://php.net/manual/en/function.ini-get.php Quote Link to comment https://forums.phpfreaks.com/topic/270270-mysql_real_escape_string-magic-quotes/#findComment-1390168 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.