HabboxWiki needs you!
Are you a Habbo buff? Or maybe a rare trader with a bunch of LTDs? Get involved with HabboxWiki to share your knowledge!
Join our team!
Whether you're raving for rares, excited for events or happy helping, there's something for you! Click here to apply
Need a helping hand?
Check out our guides for all things to help you make friends, make rooms, and make money!


Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default PHP clean() Function

    Well, I have one, but all it seems to do is unset the variable.
    Code:
    PHP Code:
    function clean($var){
    $var mysql_real_escape_string($var);
    $var stripslashes($var);
    $var htmlentities($var);
    return 
    $var;

    I already have searched for one, but there aren't any.
    I know someone on here had one before, anyone know where it is?
    i've been here for over 8 years and i don't know why

  2. #2
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    i always just use

    PHP Code:
    function clean($str)
    {
    $str strip_tags(addslashes(stripslashes(htmlspecialchars($str))));
    return 
    $str;

    Coming and going...
    Highers are getting the better of me

  3. #3

    Default

    PHP Code:
    function clean($var){
    $var mysql_real_escape_string($var);
    $var stripslashes($var);
    $var htmlentities($var);
    return 
    $var;

    What i don't get it why you've used mysql_real_escape_string which adds a \ before each " or ' then you've used stripslashes that's just gonna undo that?
    try..
    PHP Code:
    function clean($str)
    {
    $str mysql_real_escape_string($str);
    $str htmlspecialchars($str);
    $str strip_tags($str);
    return(
    $str);

    That should work..
    Last edited by Jme; 20-01-2008 at 05:05 PM.

  4. #4
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    in case of magic quotes?
    Coming and going...
    Highers are getting the better of me

  5. #5
    Join Date
    Aug 2006
    Location
    Manchester, UK
    Posts
    2,016
    Tokens
    141
    Habbo
    florx

    Latest Awards:

    Default

    Quote Originally Posted by MrCraig View Post
    i always just use

    PHP Code:
    function clean($str)
    {
    $str strip_tags(addslashes(stripslashes(htmlspecialchars($str))));
    return 
    $str;

    Why do you add slashes then remove them!??!!?! Bit pointless.

  6. #6
    Join Date
    Jun 2005
    Posts
    2,688
    Tokens
    0

    Latest Awards:

    Default

    addslashes - Should be used when inserting data into MySQL as it prevents ' characters.
    stripslashes - Should be used on output. Stripslashes removes the effects of addslashes when outputting onto a page
    htmlentities - Should be used on page output to deactivate HTML therefore if you want to use the html on some pages it is avaliable.

Posting Permissions

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