Jump to content

Trouble with forward slashes '\'.


Ultra

Recommended Posts

My site has a place where users can post comments. For some reason, whenever someone posts a single quote ['], it puts a forward slash in front of the quote. I was wondering if there was a way to get around that, like a str_ireplace(); function. I tried it, and you can't do it like this: $Comment = str_ireplace("\'", "'", $Comment); Now, due to the forum style, it makes it hard to see what I posted. With spaces: $Comment = str_ireplace(" \' ", " ' ", $Comment);

Link to comment
Share on other sites

Hm, I read something recently about the 'Magic Quote', or some such thing that used to be enabled in earlier versions of php. Not sure if this has anything to do with your problem though? I had a look a whiles back to make sure it wasn't enabled on my version of php, and though it isn't, I have no idea how you would go about disabling this feature, other than messing about in Terminal -- the Mac's command line app.

 

Having said that, I did come across this a few hours ago in another very good book on php...

 

$name = stripslashes($_REQUEST['name']);

 

Maybe someone else knows more of this?

 

 

...Typical, I've just re-read that passage, and it's only for back slashes, so it couldn't possibly have anything to do with your problem. Silly me. :rolleyes:

Edited by MacRankin
Link to comment
Share on other sites

Receive the data as POST array elements, ie: $_POST['name'].

Clean the data like so:

$clean_data = escape_data($_POST['name']);

Then, echo the $clean_data.

 

The function should remove the slashes only if the magic_quotes_gpc is active, so you use it to allow your script to function the same whether the magic_quotes is on or off.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...