Anti sql injection PHP

I need some help with a "Anti Mysql Injection" script PHP

Quote<?php
$locatie = $_SERVER['REQUEST_URI'];
$array = Array();
$array[] = "mysql";
$array[] = ")";
$array[] = ";";
$array[] = "}";
$array[] = "INSERT";
$array[] = "DROPTABLE";
$array[] = "TRUNCATE";
$array[] = "DROP";
$array[] = "UPDATE";
$array[] = "COOKIE";
$array[] = "ENV";
$array[] = "FILES";
$array[] = "GET";
$array[] = "POST";
$array[] = "REQUEST";
$array[] = "SERVER";
foreach($array As $foutbezig) {
if(eregi($foutbezig,$locatie)) {
echo "Internet fout, ip adres doorgegeven aan domein houder.";
mail("$adminmail","Mysql Injection","Mysql Injection
IP-Adres: $_SERVER[REMOTE_ADDR]","From: $sitename <$noreply>");
exit();
}
}
?>
Comments
46
Crossfire 3.2 - A Scripting Community
why did this make me think of Pale?
Parent
looks like you have no idea what you're doing, as you dont even state WHAT it is you want help with.

also variable $locatie has not been set anywhere in the above script
True everything is in config.inc.php and you can't get that one.
Parent
I dont want it.
Parent
You can't get that one.
Parent
Good luck seeking help, you seem like you know what you're doing D:
Parent
Zegt de man met de driehoek! Haha double triangle :PP
Parent
Hallo? Wat is het probleem?
And where is your problem now? xD
You know PHP?
Parent
Why not just use mysql_real_escape_string?
Parent
cuz i don't want to rebuild the admin login.
Parent
thats not a big thing.
Parent
I know, cuz i already rebuild it.
A bug: with a code you can login to the administration panel.
And i already tried it & only what i saw was PHP Error's.
Parent
PHP Error's? Ok but if you read errors there be the explanation and lines. Just check and fix???
Parent
hahaha it took me 4 days to find every error.
If i fix 1 error i will get another one & etc.
So i deleted that shit.
Parent
what are you trying to achieve with that piece of code? What you are doing is not preventing mysql injection, you are just checking strings for malicious words. If you want to prevent your SQL queries from being injected, just use mysql_real_escape_string function, easy as that...
no.. just no. It's a start, but no.. just no.
Parent
assuming he just skipped google and asked this question here implicates that mysql_real_escape_string will be sufficient for him
Parent
"assumption is the mother of all fuck ups"

He (well, actually anyone that does queries to a database) should use parameterized queries. (prepared statements)

http://www.php.net/manual/en/pdo.prepared-statements.php
Parent
maybe he should use some database abstraction library, or maybe he should take an advantage of using rich php frameworks and follow mvc standarts...
Parent
Using MVC standards have not much to do with preventing sql injections. A Database abstraction layer is an option, but hardly something he should be looking into seeing the kind of code he's doing atm. Just going for prepared statements is step 1 for him.
Parent
Why are you writing your own sql injection prevention script? (and the code btw is a quite strange way to check for sql injections)
I really doubt he wrote this
Parent
and why is that
Parent
Cool script bro
just use some vulnerably scanner like acunetix ?
Who the fuck use non-english variables in their code?
Me cuz i'm dutch*
Parent
He, obviously, because he cannot into English.
Parent
bad practice indeed.
Parent
if you are the only developer then surely it isn't of any real importance?

i sometimes use foreign language file and variable names when writing stuff for myself, as long as i know what it means i doubt it matters
Parent
Of course, most likely in his situation it doesn't matter. Doesn't change the fact that it's still bad practice which you shouldn't get used to. You never know where a piece of code might end up and what nationalities will end up working with it.
Parent
You mean like this guy just did?
The programming language is in english, hence the variables should also be in english. End of discussion :)
Parent
I hate bad practicers!
Parent
Back to top