0

I heard that mysql query variables or queries are being depreciated and it's not advisable to use them any more, well I'm trying to update my simple website and I want to add some security features for my forms and my database, I have this query below

mysql_query("UPDATE users SET first_name='$name', last_name='$name2', username='$username' , phone_number='$phone', email='$email', user_level='$user_level', type='$type' WHERE id='$id'")
 or die(mysql_error());

or

$row = mysql_fetch_array($result);

What's the best way I can write a query without being attacked?

Marcel Korpel
  • 21,536
  • 6
  • 60
  • 80
cleo
  • 91
  • 1
  • 3
  • 7

1 Answers1

1

Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.

Community
  • 1
  • 1
rekire
  • 47,260
  • 30
  • 167
  • 264