Jump to content

[SOLVED] Help with CheckAdmin Function ()


whiteboikyle

Recommended Posts

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

 

Link to comment
Share on other sites

<?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;
}
}
}
?>

Link to comment
Share on other sites

<?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 :(

Link to comment
Share on other sites

<?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;
}
}?>

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

haha thats funny.. i fixed some other stuff to.. it works now :D

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;
}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.