i need to know about how to prevent our database from sql injection, i read many blog and answer on internet but could not justify which way i should prefer or best. just like for mysql:
mysqli:
mysql_real_escape_string.
or using
Using PDO:
i know if user something inserting in database it becomes vulnerable to SQL injection, and i generally use this code for insertion:
<?php
$con=mysql_connect("localhost","root","");
$db=mysql_select_db("test",$con);
$foo=$_POST['foo'];
$boo=$_POST['boo'];
$insert="insert into table set foo='$foo',boo='$boo'";
so what should i do for prevent my database injection..... any idea would be appreciated highly.. Thanx in advance