Hi, i have a " Deprecated: mysql_real_escape_string()" and a "Deprecated: mysql_query" error while running my webpage in function.php and users.php. I would like to know how to change this following code to be uptodate
connect.php
<?php
$db = new mysqli('localhost','root','','madmax');
if ($db->connect_errno){
die('Sorry, we are having connection problems.');
}
?>
function.php
function sanitize($data){
$db = new mysqli('localhost','root','','madmax');
return htmlentities(strip_tags(mysql_real_escape_string($data)));
users.php
function user_id_from_username($username){
$username = sanitize ($username);
return mysql_result(mysql_query("SELECT `user_id` FROM `users` WHERE `username`='$username'"), 0, 'user_id');
}
Thank you in advance!