I can't collect the results of my query in this function :
<?php
function getBestScore()
{
require_once ('connection.php');
$idJoueur = session_id();
if ($stmt = $conn->prepare('SELECT bestScore FROM Player WHERE ID = ?'))
{
$stmt->bind_param('i', $idJoueur);
$stmt->execute();
$result = $stmt->get_result();
$data = $result->fetch_assoc();
$bestScore = $data;
if (!(empty($bestScore)))
{
header("Location: ../index.php");
}
return $bestScore;
}
else
{
$error = $conn->errno . ' ' . $conn->error;
echo $error;
}
}
My connection works, I tried fetch_assoc()
, store_result()
but I failed every time.