I am running a making a mobile app that uses PHP to retrieve data from a web server.
When I run the SQL statement in the sql query it returns the correct data.
when I run the PHP it returns null values for the item at location 0 in the gameArray, all other items in the array show the right values
the code is as follows
$userResponse = array(
'login' => $userName,
'nickname' => $userNickName);
$stmt = $conn->gamedb->prepare("SELECT player1, player2, currentturn, question1, question2, question3, question4, question5, question6, question7, question8, question9 FROM Game WHERE Player1 = ? OR Player2 = ?");
$stmt->bind_param('ss', $userName, $userName);
$stmt->execute();
$result = $stmt->store_result();
//create games array to be filled when stepping through the games
$gameResponse = array();
if($conn->gamedb->affected_rows > 0)
{
while ($stmt->fetch())
{
$stmt->bind_result($player1, $player2, $currentTurn,
$question1, $question2, $question3,
$question4, $question5, $question6,
$question7, $question8, $question9);
$gameArray = array($player1, $player2, $currentTurn,
$question1, $question2, $question3,
$question4, $question5, $question6,
$question7, $question8, $question9);
//stores the game data into an array
$gameResponse[] = $gameArray;
}
//close stmt
$stmt->close();
}
$response = array(
$userResponse,
$gameResponse
);
echo json_encode($response);
any help would be awesome!
affected_rows