I just had a friend of mine look over some code I'm using to get data from my database, and he tells me it's very unsecure and that SQL injection is serious shit.
Here's the code I'm using now:
$id = $_GET['id'];
$result = mysql_query("SELECT * FROM news WHERE id = $id") or die("err0r");
He tells me that the solution is to change that code into:
$id = intval($_GET['id']);
$result = mysql_query("SELECT * FROM news WHERE id = $id") or die("err0r");
My code somehow (according to my friend) makes any user able to edit content in my database:
http://mydomain.com/?p=news&id=38;DROP TABLE tablename;
Could someone explain exactly what he means?
Thank you and have a pleasant day