Zpixel wrote:mysql_real_escape_string() is good but enough?
Yes, actually, it is. It escapes characters that would otherwise interrupt the query or change its behavior.
Zpixel wrote:using common ways is very needed, but try to invent somthing as your personal way which is unknown to hackers.
That's absurd; the "common ways" you're speaking of are ones that have been developed and used for years. Since bank's commonly keep money in a secured vault, maybe they should try to trick bank robbers by hiding it in large trash bags near the trash can instead?
Zpixel wrote:if(strpos($item,$x) ) => if $item==''){mysql_query("delete ...")} => it can not defeat the code above.
Assuming you're correct, awesome; you prevented one situation out of many. Now as others chime in and mention ideas that you didn't think of, you admit that it doesn't work and then you modify the code to protect yourself against that situation. Meanwhile, those of us sitting here using mysql_real_escape_string() were already protected against all of the situations discussed already plus several more. It's less code and protects against more cases than your code does, so I fail to see why anyone would want to switch.
Can you tell us why you think it's better to have
$baned=Array('delete ','drop ','insert ','replace ','select ','truncate ','update ');
foreach($_REQUEST as $item){
$item=' ' . strtolower($item);
foreach($baned as $x)
if(strpos($item,$x) && strpos($item,'mysql_query'))
exit; // or redirect
}
than
mysql_real_escape_string($data);
?