Re: magic quotes
| From: | Chris Hewitt | Date: | Fri, 04 Apr 2003 15:35:05 +0000 |
| Subject: | Re: magic quotes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142357@lists.php.net to get a copy of this message | ||
Ford, Mike [LSS] wrote:
Regards Chris-----Original Message----- From: Chris Hewitt [mailto:g0pae@manordat.demon.co.uk] Sent: 03 April 2003 09:26 To: Justin French[snip]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:Something bugged me about this code and comment when I very first read it, but it's taken an overnight cogitate to work out what it was. Dare I venture that your previous code, which sometimes appeared to throw an error, was simply: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 (ini_set('magic_quotes_runtime','Off') == false) { echo "ERROR: Could not turn off magic_quotes_runtime\n"; }? If so, there's a fundamental flaw here: as ini_set is defined to return the previous value of the setting, or FALSE if it fails, a simple equality comparison (==) to FALSE will succeed whenever the ini_set fails *or when the previous value was 0 (off)*. To echo your error only when ini_set() genuinely returns FALSE, you must do an identity comparison (===). Yes, that was my previous code and you are right, its not right! I'll change it and thanks for letting me know.