Hi
I have been reading up on SQL Injection and I am trying to secure my scripts to prevent this. However, I am coming up against a brick wall in regards to this.
I understand the use of the mysql_real_escape_string() command to help with this, however this isnt helping me with a "union" type injection. as there are no special characters in the appended SQL statement.
So Im wondering what the best way to prevent this sort if injection is.
If the data is just a number then its quite simple, jsut remove any on numeric data before running the query, but in the case of other types where the data could be any character (like a message board message entry screen!) then such validation would not work.
so my understanding is that my code should look like this:
include(dbconnect.php);
$message = $_POST['message'];
$message = mysql_real_escape_string($message);
at this point, it should be safe against other sorts of attacks (as far as I am aware, please correct me if this is wrong)
But its not protecting me against the union attack, and I have no idea where to start on that.
I could just not allow the word union be used, but that wouldnt be a great idea, so im wondering how I do prevent this sort of attack,
Any help would be greatly appreciated.