external php script for check ban on mybb users -


guys need function add on external php script check ban on mybb users

i want function check database if user banned, return echo: line 1: banned board line 2: ban reason: $banreason line 3: ban time: $bantime

look guys dont programer know code have many problem want show need :

<?php class ban { function check_ban($uid) {   $sql = "select * mybb_banned order dateline desc limit 30";   $result=mysql_query($sql);    if($mybb->user['uid'] = $result2 ['uid'])     {      return array( 'banreason' => $result['baneason'] ,                    'bantime'   => $result[ 'bantime' ],                  );     }  } }  $result2 = $ban->check_ban( $uid );  if( $result == false ) {     echo "you banned\n" ;     echo $result[ 'banreason' ]."\n" ;     echo $result[ 'bantime' ] ; } ?> 

thank you

you assigning result id user id rather comparing them. think mixing $result , $result2

the other issue need loop through banned members , check each

a neater approach this:

class ban {         static function check_ban($username)     {       // fetch results uid       $sql = "select * mybb_banned inner join mybb_users on mybb_banned.uid = mybb_users.uid order dateline desc limit 30 mybb_users.username=$username";       $result=mysql_query($sql);        if(mysql_num_rows($result)) // check if entries returned database         {          return array( 'banreason' => $result['mybb_banned.banreason'] ,                        'bantime'   => $result[ 'mybb_banned.bantime' ],                      );         }       else return false;     } }  if( ban::check_ban( $username ) ) {     echo "you banned\n" ;     echo $result[ 'banreason' ]."\n" ;     echo $result[ 'bantime' ] ; } 

here, i've made check_ban method static don't need instantiate instance of ban before can use it.

edit: i've edited code above searches based on username joining mybb_users , mybb_banned tables (think of temporarily combining 2 tables 1 rows matched using uid)


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -