“未定义的索引”由于来自上一个查询的持久性mysqli结果[重复]

I'm building a web app for a client on a LAMP server, written in PHP with data stored in a MySQL database. In the current.php script I need to get info from two tables based on what user is signed in and a choice made on a previous page. It seems a previous query is interfering with a new query.

Problem: I'm getting the error Undefined index: col5 referring to the line marked (// ERROR HERE) below.

Attempted so far: I added the print_r($resultTwoRow); before the line in question to see inside what data was actually returned. This displays:

Array ( [0] => foo [col1] => foo [1] => bar [col2] => bar )

which is the result/row from the FIRST query. Why is that still hanging around? How can I get the row data from the second query instead?

db

======users_widget_links======
|  id  |  colOne  |  colTwo  |
|------|----------|----------|
|  123 |   foo    |   bar    |
|  666 |   FOO    |   BAR    |
==============================

=====================choices===========================
|   id   |  col1  |  col2  |  col3  |  col4  |  col5  |
|--------|--------|--------|--------|--------|--------|
|  '42'  |    0   |    1   |    1   |    1   |    0   |
|  '43'  |    1   |    1   |    0   |    0   |    1   |
=======================================================

connection.php

<?php

$host = "host";
$port = "port";
$dbname = "db";
$user = "user";
$password = "pw";

$cnxn = mysqli_connect( $host, $user, $password, $dbname );
if(!$cnxn){
    echo "Error : Unable to open database
";
}

current.php

<?php
$userID = $_SESSION['user']['user_id']; // 123 in this example
$choiceID = $_POST['choice']; // '42' in this example

/* Omitted code */

require('connection.php');
$queryOne = "SELECT users_widget_links.colOne, users_widget_links.colTwo FROM users_widget_links WHERE id = '123'";
$resultOne = mysqli_query($cnxn, $queryOne) or die(mysqli_error());
$resultOneRow = mysqli_fetch_array($resultOne); // not looping because only one result
$thingOne= $row['colOne'];
$thingTwo = $row['colTwo'];
if ($userID == '666') $thingOne = 'exception';
mysqli_close($cnxn);

require('connection.php');
$queryTwo = "SELECT `col1`, `col2`, `col3`, `col4`, `col5` FROM `tableTwo` WHERE id = '$choiceID'";
$resultTwo = mysqli_query($cnxn, $queryTwo) or die(mysqli_error());
$resultTwoRow = mysqli_fetch_array($resultTwo);  // not looping because only one result
print_r($resultTwoRow);
$columnFive = $resultTwoRow['col5']; // ERROR HERE
mysqli_close($cnxn);

/* Omitted code */

?>
</div>

you can unset the variables from the first query. by using the function unset($variable)