-2
mysql_query("INSERT INTO user_badges (user_id, badge_id) 
VALUES ('". $_SESSION['user']['id'] ."',VIP)");

How can I make this safe?

Mihai
  • 26,325
  • 7
  • 66
  • 81
IbraDigga
  • 1
  • 2

1 Answers1

1
  1. Use newer functions like mysqli_query or even better PDO library.

  2. Bind params, do not inject them in query.

  3. Sanitize your params.

Read:

About PDO, About MySQLi, About sanitizing in PHP.

Community
  • 1
  • 1
Grzegorz Gajda
  • 2,424
  • 2
  • 15
  • 23
  • @IbraDigga . . . Probably not. mysql_ is no longer supported. The correct option is to switch to mysqli. If you want security, then use supported software. – Gordon Linoff Jan 09 '16 at 18:55