0

im getting this error on my refferal system, this is because registered account dont have any player / level , i mean they are empty. if i will fill with some info there, error Notice: Trying to access array offset on value of type bool in will disapear.

if(count([$getCharsINFO]))
{
    
    echo'<tr>
          <td>'.$i++.'</td>
          <td>'.$getCharsINFO['name'].'</td> //error here
          <td>'.$getCharsINFO['level'].'</td>'; // error here
    if($getChars['claimed']==1) echo '<td><button class="btn btn-primary btn-sm disabled">'.$lang['collected'].'</button></td>';
    else {
    if($jsondataReferrals['level']<=$getCharsINFO['level'])
        echo '<td><form action="" method="post"><input type="hidden" name="id" value="'.$getChars['registered'].'"><input id="submitBtn" type="submit" name="login" value="'.$lang['collect'].'" class="btn btn-primary btn-sm"/></td></form>';
    else echo '<td><button class="btn btn-primary btn-sm disabled">'.$lang['not_yet'].'</button></td>';}
    echo'</tr>';
      $x++;

}

this is my function

function getCharData($id)
    {
        global $database;
        
        $stmt = $database->runQueryPlayer("SELECT * FROM player WHERE id=:id");
        $stmt->bindParam(':id', $id, PDO::PARAM_INT);
        $stmt->execute();
        $result=$stmt->fetch(PDO::FETCH_ASSOC);

        return $result;
    }

tried to add

if(empty($result)){
{
    echo "No Character";

}

    return $result;
}
Barmar
  • 741,623
  • 53
  • 500
  • 612
IoanaM
  • 23
  • 3

0 Answers0