php - Blind Arithmetic Evaluation Differential : SQL Injection -


i getting sql & url injection vulnerabilities when scan website. code i'm using:

if(isset($_get["id"])) {     if(!is_int($_get["id"]) ==false)     {         //redirect person homepage     } else {         $sql = "select * workshop id=".trim($_get['id']);         $result = mysql_query($sql);          $row = mysql_fetch_assoc($result);         $id = $row['id'];            $prod_name = $row['prod_name'];          $description = $row['description'];          $image1 = $row['image1'];         $image2 = $row['image2'];         $image3 = $row['image3'];         $pdffilename = $row['pdffilename'];         $publish = $row['publish'];         $workshop_date = $row['workshop_date'];         $workshop_date_end = $row['workshop_date_end'];         $course_desc = $row['course_desc'];         $attend = $row['attend'];         $trainer_detail = $row['trainer_detail'];         $location = $row['location'];          $datevalue = $row['workshop_date'];         $year = date('y',strtotime($datevalue));         $month = date('f',strtotime($datevalue));         $day = date('d',strtotime($datevalue));          $datevalue1 = $row['workshop_date_end'];         $year1 = date('y',strtotime($datevalue1));         $month1 = date('f',strtotime($datevalue1));         $day1 = date('d',strtotime($datevalue1));     } } 

how fix it?

the sql injection problem in row:

$sql = "select * workshop id=".trim($_get['id']); 

you're applying value directly query without escaping it.

do instead:

$id = mysql_real_escape_string(trim($_get['id'])); $sql = "select * workshop id=$id"; 

remember you're using deprecated mysql_* functions, mysqli_* should used instead. consider updating code.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -