Jump to content

protecting against SQL Injection without adding slashes?


crocop1

Recommended Posts

hi im sort of new to the sql thing and

 

i made a function like this to protect from xss and sql injection:

 

function protect_from_xss($s){
        $s = htmlentities($s);    
        return $s;
}

 

and

 

function protect_from_sql($s){
        $s = mysql_real_escape_string($s);
        return $s;
}

 

however, say i have a part of my website where they post comments and sometimes people will use the ' or " in their comment and it will show up as \' or \".. how can i clean it without adding slashes?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.