2

Possible Duplicate:
Best way to prevent SQL Injection in PHP

Is this code secure since i am using mysql_real_escape_string and strip_tags Is there any need to change to pdo ? I am not able to convert the following code to pdo because its displaying cannot modify header .

<?php
include('config.php');
$link =mysql_connect($db_host,$username,$password);
mysql_select_db($db_name);

$id= $_POST["uniqi"]; 
$comments= $_POST["comments"]; 
$comments= mysql_real_escape_string($comments);
$comments = strip_tags($comments);

$update = "UPDATE mastertable SET comments = '$comments' WHERE id_pk= '$id'";
mysql_query($update, $link);
mysql_close();
header('Location: http://www.xxxx.com/xxxxx/xxxx.php?cntmsg=Comment Updated');
?>
Community
  • 1
  • 1
Tom
  • 244
  • 1
  • 3
  • 15
  • 1
    You should definitely convert this to PDO - the mysql extension [is being deprecated](http://news.php.net/php.internals/53799). – DCoder Jul 08 '12 at 15:50
  • http://stackoverflow.com/questions/8028957/headers-already-sent-by-php – PeeHaa Jul 08 '12 at 15:51

1 Answers1

1

This is not safe code - your $id variable is not processed by your code.

$id= $_POST["uniqi"]; 
$id= mysql_real_escape_string($id);
$id = strip_tags($id);
Tudor Constantin
  • 26,330
  • 7
  • 49
  • 72