//************** 防注入函数
$check=eregi('and|or|where|limit|group by|select|insert|update|delete|\'|\\*|\*|\.\.\/|\.\/|union|into|load_file|outfile',$sql_str); // 进行过滤 PHP5.3以前用
//$check= preg_match('/and|or|where|limit|group by|select|insert|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile/i', $sql_str); // 进行过滤 PHP5.3以后用
if($check){
echo "你输入非法字符!";
exit();
}else{
return $sql_str;
}
}
//************** 防注入函数 完
PHP5.3以后的版本没有了eregi,所以只能用preg_match
摘自:http://www.q3060.com/list3/list117/