|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Remove extra backslashes...
Hey,
Here is a php file called 'testonlinetxt.php'. PHP Code:
Now enter http="www.sdf.com" and click on save. The page is reloaded and the text in the textarea is http=\"www.sdf.com\". Why am i getting those extra slashes? Can someone tell me how i could get rid of them? Thanks Neville |
|
#2
|
|||
|
|||
|
You probalby want stripslashes
You probably have magic quotes turned on, if you were inserting into a database some characters like " and ' will mess it up, adding a slash to these characters (" becomes \" and ' becomes \') makes it safe for the db to store. You can use addslashes to do this. Depending on your setup php will automatically call addslashes, it sounds like thats what its doing here. I cant explain this very well, anyone else care to step in...
__________________
http://www.phptutorials.cjb.net. go on, give it a click! |
|
#3
|
|||
|
|||
|
magic_quotes_gpc is pretty annoying isn't it?
Nevill,
You are having a very common problem. There are two ways to go about this, but one way is better. First, I assume you have register_globals Off If you are unsure, please check : http://forums.devarticles.com/t4391/s.html Your stock php.ini configuration is going to have : magic_quotes_gpc = On In this case, each time you post data to a page, where there is a ' or a " you will get a slash (\) prepended to it automatically. This is PHP trying to "Help You Out". Realistically, it is pretty annoying. So, you can band-aid the problem in code by doing this: PHP Code:
or, to eliminate the problem completely, you can just do the following: In php.ini: magic_quotes_gpc = Off or In .htaccess php_value magic_quotes_gpc off Now, keep in mind, if you turn off magic_quotes_gpc and you actually need to escape quotes in your data such as inserting into a database, embedding strings inside of javascript, etc, you will have to use the function addslashes. This is ok... it is not as annoying as having to stripslashes everything. My suggestion is to turn it off in php.ini or .htaccess.
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Remove extra backslashes... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|