whiteboikyle Posted April 16, 2008 Share Posted April 16, 2008 Okay well i have 2 problems i think... Well its a members page.. i want on it to view something if your rank is 27 or higer... Well.. here is the function function CheckAdmin($username) { global $dbprefix; $query = "SELECT * FROM {$dbprefix}members WHERE username = '$username'"; $result = mysql_query($query) or die(mysql_error()); $ro1 = mysql_fetch_array($result); @extract($row); foreach($row AS $key => $value) { ${$key} = textFilter($value); } if($rank >= '27') { return true; } else { return false; } } Which doesn't work.. Well on the members page i have it like this if(CheckAdmin($filterUsername)) { echo "<td class='main' align='center' width='100' style='border-style:solid; border-color:#141b23; border-width:1px;'>";getMemberAdmin($Username);"</td>"; } $filerUsername is the user logged in and $username is the member being displayed.. Well.. here is the function for getMemberAdmin function getMemberAdmin($uname) { global $dbprefix; $query = "SELECT * FROM {$dbprefix}members WHERE username = '$uname'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); @extract($row); $date_joined = date("F j, Y", $datejoined); $daysinclan = round((time() - $datejoined)/86400); if($daysinclan >= '10') { } else { echo("<img src='themes/extendeddarkblue/images/misc_help/3.png'>"); } } which works completly.. Well the thing is i think it might have an effect if both functions are pulling out of the member table.. Well let me know if you can get my function to work or if you can explain this to me.. Thanks, Whitey Quote Link to comment Share on other sites More sharing options...
redarrow Posted April 16, 2008 Share Posted April 16, 2008 <?php // database connection... function CheckAdmin($username) { $query = "SELECT * FROM members WHERE username = '$username'"; $result = mysql_query($query) or die(mysql_error()); while($row=mysql-fetch_assoc($result)){ if($row['rank']>=27){ return true; }else{ return false; } } } ?> Quote Link to comment Share on other sites More sharing options...
whiteboikyle Posted April 16, 2008 Author Share Posted April 16, 2008 <?php function CheckAdmin($username) { global $dbprefix; $query = "SELECT * FROM {$dbprefix}members WHERE username = '$username'"; $result = mysql_query($query) or die(mysql_error()); while($row=mysql-fetch_assoc($result)) { if($row['rank']>=27) { return true; } else { return false; } } } ?> Dont Work Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted April 16, 2008 Share Posted April 16, 2008 <?php function CheckAdmin($username) { global $dbprefix; $query = "SELECT * FROM {$dbprefix}members WHERE username = '$username'"; $result = mysql_query($query) or die(mysql_error()); while($row=mysql-fetch_assoc($result)) { if($row['rank']>=27) { return true; } else if($row['rank']<27) { return false; } }?> Quote Link to comment Share on other sites More sharing options...
whiteboikyle Posted April 16, 2008 Author Share Posted April 16, 2008 again doesn't work.. i think it has to do with the double query looking at the same table.. its only showing the first username.. all the other members wont display Quote Link to comment Share on other sites More sharing options...
whiteboikyle Posted April 16, 2008 Author Share Posted April 16, 2008 CLEANED IT UP MORE BUT STILL WONT WORK!!!! function checkAdmin($user, $rank) { global $dbprefix; $query = "SELECT '$username' FROM {$dbprefix}members"; $result = mysql_query($query) or die(mysql_error()); while($row=mysql-fetch_assoc($result)) { if($row['rank'] >= '$rank') { return true; } else { return false; } } } echo "</font></td><td class='main' align='center' width='100' style='border-style:solid; border-color:#141b23; border-width:1px;'>$status</td>"; $date_joined = date("F j, Y", $datejoined); $daysinclan = round((time() - $datejoined)/86400); if (checkAdmin($filterUsername, '27')) { echo "<td class='main' align='center' width='100' style='border-style:solid; border-color:#141b23; border-width:1px;'>"; if($daysinclan <= '5') { echo("<img src='themes/extendeddarkblue/images/misc_help/3.png'>"); } elseif($daysinclan <= '10') { echo("<img src='themes/extendeddarkblue/images/misc_help/6.png'>"); } elseif($daysinclan <= '20') { echo("<img src='themes/extendeddarkblue/images/misc_help/5.png'>"); } elseif($daysinclan <= '40') { echo("<img src='themes/extendeddarkblue/images/misc_help/4.png'>"); } else { } echo "</td>"; } else { echo ("test"); } okay well when i view the members page.. it comes up neither my echo (test) or the <img>.. So.. i dont understand whats wrong.. =/ and only shows 1 user out of 100.. and it seems like it dies when it gets to that part.. Quote Link to comment Share on other sites More sharing options...
whiteboikyle Posted April 16, 2008 Author Share Posted April 16, 2008 bump and btw sorry for not putting code tags.. but wont let me edit it =/ Quote Link to comment Share on other sites More sharing options...
conker87 Posted April 16, 2008 Share Posted April 16, 2008 I'm surprised noone noticed this: while($row=mysql-fetch_assoc($result)) should be while($row=mysql_fetch_assoc($result)) Quote Link to comment Share on other sites More sharing options...
whiteboikyle Posted April 16, 2008 Author Share Posted April 16, 2008 haha thats funny.. i fixed some other stuff to.. it works now function CheckAdmin($username, $ranklevel) { global $dbprefix; $query = "SELECT * FROM {$dbprefix}members WHERE username = '$username'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); @extract($row); foreach($row AS $key => $value) { ${$key} = textFilter($value); } if($rank >= $ranklevel) { return true; } else { return false; } } Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted April 16, 2008 Share Posted April 16, 2008 topicsolved please Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.