'My code keeps on returning 'notrunning' even though I already started the game on the teachers side what could be wrong?

Even though I already started the game on the teacher's side, the code keeps on returning 'notrunning' so does this just mean that is_null($result[0])?

<?php
    session_start();

    // If $_SESSION['time'] is set, the user has not ended the previous game
    if (isset($_SESSION['time'])) exit('started');

    // If all 3 rounds are filled, the game has already been finished
    if (isset($_SESSION['round']))
        if (isset($_SESSION['words'][0]) && isset($_SESSION['words'][1]) && isset($_SESSION['words'][2]))
            exit('complete');

    require '../dbconn.php';

    // Get the characters from the database
    $get_grid = $dbh->prepare('SELECT started, grid FROM games WHERE password = ?');

    if (empty($_SESSION['password'])) exit('notloggedin');
    if ($get_grid->execute([$_SESSION['password']])) {
        $result = $get_grid->fetch();
        
        // If "started" is null, the teacher has not started the game
        if (is_null($result[0]))
            exit('notrunning');

        // If "round" has not changed, the teacher has not moved on
        if (isset($_SESSION['round']))
            if ($_SESSION['round'] == $result[0])
                exit('notyet');
        // If all checks pass, send the characters
        echo json_encode(json_decode($result[1])[($result[0])]);
        $_SESSION['time'] = microtime(true);
        $_SESSION['round'] = $result[0];
    }
    else exit('mysql');
?>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source