HELP! how to remove / in apostrophe

Discussion in 'PHP' started by buknoii, Nov 9, 2008.

  1. #1
    hi there! i want to ask if someone in here got an idea on how to remove the \ in apostrophes?

    because everytime i access content in my database and if it has ' it also displays \

    for example cricket\'s should be crickets
     
    buknoii, Nov 9, 2008 IP
  2. keiths

    keiths Peon

    Messages:
    109
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can use the function stripslashes - http://us2.php.net/stripslashes

    Use it like this:

    
    <?php
    $var = "cricket\'s";
    $var = stripslashes($var);
    echo $var;
    ?>
    
    PHP:
     
    keiths, Nov 9, 2008 IP
  3. garrettheel

    garrettheel Peon

    Messages:
    341
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The reason it does it is to sanitize user input to stop anybody executing their own code on your database. Just use stripslashes() on all output like the person above me said.
     
    garrettheel, Nov 9, 2008 IP