Doesn't work htmlentities(); in my host! HELP

Discussion in 'PHP' started by AleckProg, Apr 20, 2007.

  1. #1
    Hello,

    I'm hosted my tagboard at PHONEACCESS hosting, and its PHP does not accept htmlentities(); or htmlspecialchars(); and I need help to solve those fails for avoid injections in my script by codes as <script>, <a href>...

    Part of code is

    $mensaje = htmlspecialchars(trim($_POST['mensaje'], ENT_QUOTES));
    PHP:
    Please help me to another way for avoid this without htmlspecialschars().
     
    AleckProg, Apr 20, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    You should close trim()'s parenthesis after the $_POST variable. At the moment you're applying ENT_QUOTES to trim(), and not htmlspecialchars().
     
    nico_swd, Apr 20, 2007 IP
  3. AleckProg

    AleckProg Guest

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Nothing, I using thus:

    $mensaje = htmlspecialchars(trim($_POST['mensaje']), ENT_QUOTES);

    But doesn't work yet. HELP ME :S

    THE PROBLEM IS, THAT MY HOST DOESN'T ACCEPT HTMLENTITIES(); FUNCTION, WHAT CAN I DO IN THIS SITUATION?
     
    AleckProg, Apr 20, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    I almost can't imagine it being a problem with the host. Why on earth would they disable one of the most basic and harmless functions?

    However, you can use str_replace() to emulate the function. But I guess it's a usage error, rather than a problem with the host...
     
    nico_swd, Apr 20, 2007 IP