Mysql Php Escaping single quotes with real_escape_string -
i having trouble figuring out how clean strings safe queries while maintaining meaning of string. given table of values have single quotes or other escapable characters. how use real_escape_string , still select values?
my_table
col1 col2 ----------------- 1 value's1 2 value's2
value's1 coming url have clean mysqli::real_escape_string means query looks this
select col1,col2 my_table col2 = 'value\'s1'
and of course because of getting no results returned.
what various strategies dealing problem?
note: did phpinfo() , magic_quotes_gpc 'off'. neccessary me clean value don't see how sql injection when php allows 1 query @ time? being on cautious?
if(get_magic_quotes_gpc()) { $string = stripslashes($string); $string = mysqli_real_escape_string($string); } else { $string = mysqli_real_escape_string($string); }
you might want make function out of this
Comments
Post a Comment