Forum Moderators: coopster
static public function memberLevel($g_id, $u_id){
global $database;
$result = $database->query("SELECT level FROM ".TBL_MEMBERS." WHERE
group_id = ".$g_id." AND
user_id = ".$u_id);
if(mysql_numrows($result) == 0) return false;
else return mysql_result($result,0,0);
}
Class::memberLevel(1, 1) === 4 //this would return false
Class::memberLevel(1,1,) === "4" //this would return true
string mysql_result [us.php.net] ( resource $result , int $row [, mixed $field ] )
So if it's really important (since you have the 'workaround' working it may not be much of an issue now) you'll probably want to test different table types to see what's what (lol or I suppose it may just be documented somewhere ;) ).
mysql_fetch_array [php.net] and other fetch operations do the same thing ...
Return ValuesReturns an array of strings that corresponds to the fetched row, ...
my emphasis added
In order to get an integer value you either have to cast it as such like you did or use it in an operation that requires PHP to convert it to a numeric value.
Now I see what I did - sometime before the grand idea to test on a different table type I'd changed from is_int() to is_numeric() just to double-check that I wasn't daffy, and I forgot to change it back (I'm using a script that I keep reusing for WW posts/tests - I stuck the fetch at the top but the is_int() & echo are 40 lines down).