Re: magic quotes
| From: | Chris Hewitt | Date: | Thu, 03 Apr 2003 08:26:18 +0000 |
| Subject: | Re: magic quotes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142092@lists.php.net to get a copy of this message | ||
Justin French wrote:
Hi all, Can I just have a quick head check on magic quotes runtime (&gpc)? I have them both set to Off currently, and my pages work fine. However, when I set them to on, I end up with slashes throughout the mysql data. Is this the expected behaviour? Seems counter-intuitive to me, but I've never really cared about it 'till today, because i've never had a problem!! What is a common setting for these two directives, so that I can have my LAN server *reasonably* "normal". The defaults are runtime off and gpc on. As you refer specifically to slashes in mysql data I assume that the runtime one is more relevant to what you are doing. If your code runs properly with runtime off then you are doing the addslashes/stripslashes as intended. With the same code and runtime on then you will get double slashes.I had reason to look at this in the manual yesterday and it seems the magic_quotes_runtime turned on is aimed more at beginners (but I could be wrong). What I have done is to do the addslashes/stripslashes assuming magic_quotes_runtime is off then force it off within my code beforehand with:
if (ini_get('magic_quotes_runtime') == 1)
{
if (ini_set('magic_quotes_runtime','Off') == false)
{
echo "ERROR: Could not turn off magic_quotes_runtime\n";
}
}
I found that ini_set would through an error if the seting was already made, hence the initial check. So far this seems OK, but it was only yesterday...
If anyone else has a better suggestion, I'd be pleased to hear it.
HTH
Chris