Forum Moderators: coopster

Message Too Old, No Replies

Removing the backslashes

         

brendan3eb

10:30 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



$code = $_POST['code'];
fwrite($handle, $code);
mysql_query("INSERT code..blah blah");

my code looks something like that. I'm taking some html from a form and putting it both in a file and into mySQL. However, this code adds backslashes to everything. The file $code is written to has three backslashes before each double quote, and the $code put into mysql has a backslash before each doublequote once. How can I stop these doublequotes from appearing?

sned

10:44 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



It sounds like your magic_quotes [us4.php.net] are off. Not that that's a bad thing ...

You could try using stripslashes [us4.php.net]. That should get rid of a few slashes.

Hope that helps
-sned

<edit>
oops, I did mean magic_quotes are on.
</edit>

[edited by: sned at 10:53 pm (utc) on June 20, 2005]

jatar_k

10:47 pm on Jun 20, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> are off

I think you meant 'on'

you can test this using get_magic_quotes_gpc [php.net]

as sned said stripslashes should work.

Another thing to think about brendan3eb, hopefully you do some validation on those post vars before firing them off to the db or the file, someone could post something nasty in there and if you aren't checking it, you could have some problems.