Tuesday 20 December 2016

Warning for mysql_fetch_assoc() in php

Below is the Warning message getting:




Warning: mysql_fetch_assoc() expects parameter 1 to be resource,
object given in E:\HTML Learn\Hocus\profile.php on line 11




line 11 is :




$get = mysql_fetch_assoc($check);


full code:




if (isset($_GET['u']))
{
$username = mysqli_real_escape_string($conn, $_GET['u']);

if (ctype_alnum($username))
{
//cek user
$conn = mysqli_connect("localhost", "root", "") or die("error MYSQL");
mysqli_select_db($conn, 'skey');
$check = mysqli_query($conn, "SELECT username, first_name FROM users WHERE username='$username'");
if (mysqli_num_rows($check)==1)
{
$get = mysql_fetch_assoc($check);
$username = $get['username'];

$firstname = $get['first_name'];
}
else
{
echo "

User tidak terdaftar

";
exit();
}
}
}
?>

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...