tags:

views:

16

answers:

1

hi, i am using rawurlencode($url_variable) while passing to a script.. when i receive the variable in the script ,before passing this variable to mysql ,i was doing mysql_real_escape_string . now the problem is like when there is a variable like

$url_variable = "Off-St.Mark's-Road" ...after i do mysql_real_escape_string it become slike

Off-St.Mark\\'s-Road .

which is creating a problem in mysql query ...

how i get over this...rawurlencode is necessary to pass variables to the script and i want to do mysql_real_escape_string to make the data safe...

+2  A: 

Looks like magic_quotes_gpc is turned on on your server, try this:

if (get_magic_quotes_gpc())
{
   $text = stripslashes($your_var);
}

$text = mysql_real_escape_string($text);
Sarfraz
I have a small doubt..does rawurlencode add \ to escape the quotes?
pradeep
@pradeep: I don't think so, most likely you have `magic_quotes_gpc` turned on.
Sarfraz
okie..thanks for the help...i found this script ...hope its useful for othersfunction sanitize($input){ if(is_array($input)){ foreach($input as $k=>$i){ $output[$k]=sanitize($i); } } else{ if(get_magic_quotes_gpc()){ $input=stripslashes($input); } $output=mysql_real_escape_string($input); } return $output;}
pradeep