I use is_numeric for everything, the only input I get from users is a form with an Student ID number....
I recently was reading up on SQL Injections and was wondering if the following precaution is necessary?
Currently I have:
if(is_numeric($_POST['sid']){
$sid = $_POST['sid'];
$query = "select * from student where sid='".$sid."'";
// More Code...
}
What I've read is safer
if(is_numeric($_POST['sid']){
$sid = (int) $_POST['sid'];
$query = "select * from student where sid='".$sid."'";
// More Code...
}
Is one version really safer than the other? How would someone bypass 'is_numeric'?
Also, would this be any less safe than what I currently have?
if(is_numeric($_POST['sid']){
$query = "select * from student where sid='".$_POST['sid']."'";
// More Code...
}
So, I guess what I am really asking, is if one of these code blocks is truly safer than another one
EDIT: Sorry I didn't state this early but I am using oracle 10g database, not mysql. With oci_connect();