1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

stripslashes question

Discussion in 'PHP' started by mikemdg, Jul 6, 2011.

  1. #1
    I've got some files that call variables from php but I'm not sure how to apply the stripslashes function in the format it's in.

    Here is what my variables look like:

    {$t['firstname']}
    {$t['lastname']} etc...

    I tried this but doesn't seem to work, I'm probably just putting it in the wrong place?
    {stripslashes($t['firstname']);}

    How to I remove slashes from a variable like the above?
    Thanks.
     
    mikemdg, Jul 6, 2011 IP
  2. ntomsheck

    ntomsheck Peon

    Messages:
    87
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    stripslashes only removes back slashes. If you have 'display errors' turned on and you don't see any errors, that means you're using stripslashes() correctly, it just doesn't have anything to strip. If it's forward slashes you're removing, using a preg_replace() function.
     
    ntomsheck, Jul 6, 2011 IP
  3. mikemdg

    mikemdg Member

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    Yes, it's forward slashes, but I'm pretty sure I used it on another variable (stripslashes) and it worked. It was in a different format though.
    stripslashes($variable); rather than the above.
     
    mikemdg, Jul 6, 2011 IP
  4. Kyosys

    Kyosys Peon

    Messages:
    226
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    str_replace('/','',$t['firstname']);
     
    Kyosys, Jul 6, 2011 IP
  5. elixiusx

    elixiusx Peon

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #5
    Please give us all the line.

    If for example the code are something like:
    $sql = "SELECT * FROM people WHERE name = '{$t['firstname']}'";

    You need to replace the code to:
    $sql = "SELECT * FROM people WHERE name = '".stripslashes($t['firstname'])."'";

    So you can't do something like:
    $sql = "SELECT * FROM people WHERE name = 'stripslashes({$t['firstname']})'";
     
    elixiusx, Jul 7, 2011 IP
  6. sinha.sidhi

    sinha.sidhi Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    'stripslashes({$t['firstname']})'
     
    sinha.sidhi, Jul 19, 2011 IP