Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Posts
    438
    Thanks
    9
    Thanked 7 Times in 7 Posts

    stripslashes help

    All,
    I have the following code:
    PHP Code:
    $message mysql_real_escape_string(stripslashes($_POST['message'])); 
    If I put the following text in a text field and submit it my output is:
    This is a test email. Please respond to this. Thank\'s for understanding.

    How can I get the slash out of the output?

    Thanks in advance.

  • #2
    New Coder
    Join Date
    Oct 2010
    Posts
    29
    Thanks
    0
    Thanked 2 Times in 2 Posts
    I'm not sure that I follow what you're trying to do. Maybe more code would give a better perspective. But from what I can see:

    Obviously the stripslashes() function will remove slashes, but then you are using mysql_real_escape_string which puts them back. Are you using this in a mysql query? If not, I would just take out the mysql_real_escape_string() function, and the problem should be solved.

    I always seem to have problems with slashes. They can be tricky.

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Stripslashes should only be used in the event that magic_quotes_gpc is enabled. Otherwise you will strip out intended escape characters.
    This isn't enough information. Once you have retrieve the message from the textarea, is it then presented to the database and later retrieved and displayed, or are you saying it does this immediately after printing it without storing in the database.
    If its coming from a database, check to ensure that mysql_real_escape_string has not been called twice. If you check your dataset itself, it should be without the escape characters in the database.
    If it doesn't have the escape characters in the database yet still shows with them in the textarea, check the runtime configurations for magic_quotes_runtime. Those should be set to 0. Unlike magic_quotes_gpc though, the magic_quotes_runtime can be disabled at any level.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •