Jump to content

Recommended Posts

Posted

How do i remove the / that appears when theres a ' in php.

Very brief but i dont think i can tell you anything else,

 

Thanks

Jack Dunn

Posted

You may have a deeper issue - the \ is an escape character, and it is there to stop the ' or " or any other "special" character being taken literally. Just removing the \ *may* not be a great idea.

 

What exactly is it you are trying to do?

You should ask yourself:

* Do i need to use this data in escaped form

* What is escaping the data, and can i stop it happening if i don't need it?

 

Long time since i've done PHP, but ISTR there being a few php.ini options regarding escaping - anyone refresh my memory? ;)

Posted
stripslashes() should do it as always more info on php.net - http://uk2.php.net/manual/en/function.stripslashes.php , but pay attention to what Tom said especially if your dealing with a database as you may be opening yourself up to SQL injection attack.

 

Just as a note on that... One trick that often works is to do a preg_replace() on any input and replace ' with '' (that's two single quotes btw!) which will stop any injection routines and is the same as an escaped ' in MySQL.

 

For more info' this ref is quite useful.

 

http://dev.mysql.com/doc/refman/5.0/en/string-syntax.html

 

There are several ways to include quote characters within a string:

 

*

 

A “'” inside a string quoted with “'” may be written as “''”.

*

 

A “"” inside a string quoted with “"” may be written as “""”.

*

 

Precede the quote character by an escape character (“\”).

*

 

A “'” inside a string quoted with “"” needs no special treatment and need not be doubled or escaped. In the same way, “"” inside a string quoted with “'” needs no special treatment.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...