Are you a Google Analytics enthusiast?
More SEO Content
Posted 30 January 2005 - 06:29 PM
Posted 30 January 2005 - 06:49 PM
Now I'm also assuming you want to maintain the quotes, so it's going to be a bit of a two-step process.
First you need to use addslahes so that stuff like the " and ' charactrs are escaped before dropping them in your database. So something like:
That'll get the full text string into your database, with the additional backslashes to escape those charaters that need it.
Then when retrieving the data back into a page, you'll want to strip those extra slashes back out of your string. So:
Or you could always just turn magic_quotes_gpc on and avoid all of that fun. Many php developers who have no idea where their code will end up set up little functions to test for magic quotes. But if you're designing for a single environment that shouldn't be needed.
Posted 30 January 2005 - 07:30 PM
magic_quotes_gpc On On
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off
I not sure what sybase is? But if magic quotes is on and this is still an issue, am i forced to use the addslashes function?
Posted 30 January 2005 - 09:17 PM
The problem is that there are too many variables in the mix for me to give one stock answer. The best thing to do is test it on your server to see what works and what doesn't.
I'll link to the php.net pages for both for your reference, because basically they're a pain in the tush. Especially when you start considering different server and database configurations.
Generally speaking, when magic_quotes-gpc is turned ON (as it is on most servers) you shouldn't need to use addslashes if you're doing a GET, POST or inserting data into a cookie. However you probably will need it to insert data into your database in order to make sure certain characters are escaped. If you don't your db entry is likely going to get truncated, just as you've described.
In theory, you shouldn't have to stripslashes() when retrieving info from your database because gpc is already turned on. But that doesn't always turn out to be the case.
Given what you've described, I would first try addslashes() when inserting the info into your database, but don't stripslashes() when retrieving it. That should work with a typical setup that you've described and keep from using any extra processing power for something that isn't needed.
If it doesn't you'll know it right away when you echo the variable after retrieving it from your database.
Posted 30 January 2005 - 09:18 PM
Posted 30 January 2005 - 09:25 PM
Posted 31 January 2005 - 07:04 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users