Jump to content

odd PHP MySQL prob


dt192

Recommended Posts

Hi, I am using the following function:

 

function clean_text($text, $filter) {

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

if($filter=='unclean'){return htmlspecialchars(stripslashes($text), ENT_NOQUOTES);}

else if($filter=='N'){return mysql_real_escape_string(preg_replace('/[^0-9]/', '', $text));}

else if($filter=='AN'){return mysql_real_escape_string(preg_replace('/[^a-zA-Z0-9]/', '', $text));}

else{return mysql_real_escape_string($text);}

}

 

if i use it with the following code:

 

$string="¬!\"£$%^&*()_+{}:@~<>?`-=[];'#,./<br/>";

echo $string.'<br/>';

echo clean_text($string,'').'<br/>';

echo clean_text($string,'unclean').'<br/>';

 

I get:

 

¬!"£$%^&*()_+{}:@~<>?`-=[];'#,./<br/>

¬!\"£$%^&*()_+{}:@~<>?`-=[];\'#,./<br/>

¬!"£$%^&*()_+{}:@~<>?`-=[];'#,./<br/>

 

which is exactly what i want but when i use the same code on my hosted web site and insert it into the MYSQL database i get:

 

¬!"£$%^

 

any idea what's going wrong?

Link to comment
https://forums.phpfreaks.com/topic/144436-odd-php-mysql-prob/
Share on other sites

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.