Jump to content

[SOLVED] annoying.. resource id #5


Mr. R

Recommended Posts

Hi, i have this annoying little problem when trying to see the rank of a user, this is the simple bit of code im using...

 

$result = (mysql_query("SELECT rank FROM users WHERE username = '$username'"));
if ($result == "admin") {
echo "You are an admin.";
}else{
	echo "You are not an admin";
	echo $result;
}

 

Even though the user is an admin, the output i get is... "You are not an adminResource id #5"

 

 

Can anyone help me?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/67571-solved-annoying-resource-id-5/
Share on other sites

<?php

$result = mysql_query("SELECT rank FROM users WHERE username = '$username'");
$row = mysql_fetch_assoc($result);

if ($row['rank'] == "admin") {
  echo "You are an admin.";
}else{
	echo "You are not an admin";
	echo $row['rank'];
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.