
Originally Posted by
joopie
And what if we insert a post value in the query without filtering? O hee, i remembering it. Its called a SQL injection...
Posted via Mobile Device
What? Inserting a post value? What?
If you protect whats inside mysql_query(); you will be fine, if you don't, you wont be protected and then you'll have problems (aka SQL injection).
Edit:
Example.
PHP Code:
public function Example()
{
$sql = "UPDATE table SET row = '".$data."' WHERE id = '".mysql_real_escape_string($id)."' LIMIT 1";
return (mysql_query($sql));
}
Notice how I protect the data? Try it while using $_POST, you'll be protected as I said you would.
Also, want to see it in live action? http://www.talan.x10.bz/
Here's a function I'm using upon registering.
PHP Code:
$sql = "INSERT INTO `users` (`Username`, `Password`, `Email`, `Rank`, `About`, `Background`, `Active`, `SignUp`, `TimeStamp`)
VALUES ('".$db->sql_escape($this->clean_username)."','".$password."','".$db->sql_escape($this->clean_email)."','2','Profile has not been updated since registering.','1','1','".time()."','0')";
$db->sql_query($sql);
$db->sql_escape() is what protects my data, basically it's mysql_real_escape_string. None of my $_POSTs or $_GETs are filtered with it, because everything is already protected.