-2

I am New to development.I have created an simple html 5 game for facebook .I use post Request to update.php to store score in database.

Below is my code

<? 
include 'config.php';
mysql_connect(localhost,$user,$password);
$id = mysql_real_escape_string($_POST['id']);
$score = mysql_real_escape_string($_POST['score']);
@mysql_select_db($database) or die( "Unable to select database");
$query = "UPDATE heli SET score = '$score' WHERE app = '$id'";
echo $query;
$result=mysql_query($query);
mysql_close();
?>

Many Complain that my code is vulnerable to Sql injection.Any one Suggest good code that is Secure.Thanks..

Vishnu Vishwa
  • 210
  • 1
  • 2
  • 8

2 Answers2

4

use PDO or MySQLi Extension on PHP. Please read the article below,

Community
  • 1
  • 1
John Woo
  • 258,903
  • 69
  • 498
  • 492
1

No, your current code is not vulnerable. However your other code can be.
As long as you're taking mysql_real_escape_string() as a sort of "universal injection preventor", you are in danger.

Here is an answer with explanations I gave to similar question

Community
  • 1
  • 1
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345