begin of fix
As a webmaster, sql and the millions of other attacks are a right annoyance to say the least.
Its true its impossible to stop them, but you can build sites that wont make it easy.
For example if a user enters something, such as a real name we know people dont have 200 character names, so say 15 characters for a first name and 17 characters for a double barrel second name usually is enough. Maxchars = 15. that gives them 15 characters on a form post to use, but there not likely to use your form, so repeat it on the processing page, limit the post characters to 15 as well. do the same for every type of input.
That works for simple single entry items, but exploits can be very small '0=0 so you need to render those useless as well, so where available you use magic quotes and stripslashes and addslashes etc.
Then theres text that users can enter, that needs to be handled and turned into nothing more than a comment, and weblinks shouldnt be allowed in there, you overlay those afterwards by using a whitelist NOT a blacklist.
So then a user entering data on the forn, or sending data direct to the processing page has less options, and thats STILL NOT SECURE.
You then need to code the page so it understands the data its being fed, so if an attempt is made to try and trip up the page or overflow the page the code itself will reject the stream. And even that code needs to be secure so itself cant be used for the attack, some windows attacks use the very protection to initiate it.
The rest is damage limitation, for example banks use ssl for a reason, and even then they have been hacked too, so no matter what you do someone will given enough time find a way round it, but when people find exploits, why dont other groups form together to counter them?
im sure a group of dedicated people, could create classes in all languages that would prevent much of this occuring for others to learn from, but then you get arrested and put in jail under uk law - because you "made available information" by accident as well that can be used for bad things.
A webmasters life is a boring thankless one which is a constant battle. And its why i dont like these people who create new and exotic methods to really mess up my day.