0

how would i add mysql_real_escape_string() function to the $password_md5 and $username ? help would be appreciated

$query="UPDATE `users` SET `password` = '$password_md5' WHERE `username` = '$username'";

can some body give me the script for that please i forgot how to to it. a example would really help me out

Ben
  • 8,894
  • 7
  • 44
  • 80
  • What are you trying to accomplish? – Ben Nov 05 '15 at 09:46
  • i am trying to update my password field i just need to know how can i add mysql_real_escape_string function in my query can i get a example on my query –  Nov 05 '15 at 09:47
  • @kunz you got some answers, if I was you I will switch off to mysqli or pdo, future wise it is worth it for your project. – Maytham Fahmi Nov 05 '15 at 09:58
  • Seriously, have you ever read the manual? The [example provided in the manual](http://php.net/manual/en/function.mysql-real-escape-string.php) is exactly what you are asking for >. – RandomSeed Nov 05 '15 at 10:36

2 Answers2

0
$query="UPDATE users SET password = '".mysql_real_escape_string($password_md5)."' WHERE username = '".mysql_real_escape_string($username)."'";
tino.codes
  • 1,512
  • 1
  • 12
  • 23
0
$username = mysql_real_escape_string($_POST['username']);
$password_md5= mysql_real_escape_string(md5($_POST['password']));
$query="UPDATE `users` SET `password` = '$password_md5' WHERE `username` = '$username'";
user-4653387
  • 305
  • 1
  • 4
  • 17