Get questions that haven't been showed from mysql database with php
===

We have a list of questions in a MySQL database and want it to show a random approved question to the user. When you click the Random button, we want another random question to be shown, but not any of the ones the user has already seen.

I'm trying to use something like this (but it doesn't work, just gives a blank page):

    <?php
    
    mysql_connect("localhost", "username", "password") or die(mysql_error());
    mysql_select_db("aldrig") or die(mysql_error());
    
    $result = mysql_query("SELECT * FROM spg WHERE approved='1'") or die(mysql_error());
    $answers = mysql_fetch_array($result);
    
    start_session();
    
    if (isset($_COOKIE["answers"]))
        $alreadyShownAnswers = json_decode($_COOKIE["answers"]);
    else
        $alreadyShownAnswers = array();
    
    $answerToShow = $answers[$randomIndex];
    $alreadyShownAnswers[] = $answers[$randomIndex];
    unset($answers[$randomIndex]);
    $answers = array_values($answers);
    
    echo "<div class='contentTitle'><h1>";
    echo $answerToShow; 
    echo "</h1></div>";
    
    $_COOKIE["answers"] = json_encode(alreadyShownAnswers);
    
    ?>

Can anyone tell me what's wrong?