i need to retrieve the username from the table users but i am using mysql_real_escape_string but it is giving me the error :
( ! ) Fatal error: Uncaught Error: Call to undefined function mysql_real_escape_string() in C:\wamp64\www\final-project\profile.php on line 4
( ! ) Error: Call to undefined function mysql_real_escape_string() in C:\wamp64\www\final-project\profile.php on line 4
Call Stack
# Time Memory Function Location
1 0.0014 368024 {main}( ) ...\profile.php:0
the code is :
<?php include("./inc/header.inc.php");?>
<?php
if(isset($_GET['u'])) {
$username = mysql_real_escape_string($_GET['u']);
if(ctype_alnum($username)){
//check if user exist
$check = DB::query("SELECT username FROM users WHERE username='$username'");
if(mysql_num_rows($check)==1){
$get = mysql_fetch_assoc($check);
$username = $get['username'];
}else{
echo "<meta http-equiv=\"refresh\"0; url=http://localhost/final-project/index.php\">";
exit();
}
}
}
?>
<h2>Profile page for : <?php echo "$username";?></h2>
the if(isset($_GET['u'])) is returning the username