Re: Carriage returns

From: Date: Fri, 18 Oct 2002 20:24:20 +0000
Subject: Re: Carriage returns
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-120560@lists.php.net to get a copy of this message
> You want to use addslashes before you store it in the database. When you > retrieve the data, you want to use removeslashes to convert things back. I remember getting corrected on this a long time ago. You do _not_ need to use stripslashes() on data that's coming back out of the database. If you have a string such as "that's it" and you escape the single quote, you'll have "that\'s it". When that string is inserted into the database, the \ is only there to tell the database that the next character is escaped and it's not the end of the string. So what's actually stored in the database is "that's it". You don't need to stripslash() that. Now, if for some reason you're pulling data out of the database and it comes out as "that\'s it", then one of two things is happening. You are running addslashes() twice on the data, possibly once with magic_quotes_gpc and the other with addslashes() in your code. Or, you have magic_quotes_runtime ON, which will automatically addslash() quotes when you pull data out of the database. Hope that helps. ---John Holmes...

« previous php.general (#120560) next »