First mysqli_query is working just fine and is getting a result, but the second one isn't making it past the if condition, it's like $result
is returning false.
I saw similar questions but non of them seemed to be the problem I am looking for.
I just want to point out that there is no problem in the sql statement its working fine in the database.
session_start();
$username = $_SESSION['username'];
$id = $_SESSION['id'];
//FIRST SQL QUERY
$sql = "call getrounds($id);";
if($result = mysqli_query($conn, $sql))
{
while($row = mysqli_fetch_assoc($result))
{
if($row['winner'] == "Player"){
$playerstatus="Win";
$botstatus="Lose";
}else if($row['winner'] == "Epsilon"){
$playerstatus="Lose";
$botstatus="Win";
}else{
$playerstatus="Draw";
$botstatus="Draw";
}
echo "<script type=text/javascript>createRow('".$username."','Epsilon',".$row['playerscore'].",".$row['botscore'].",'".$playerstatus."','".$botstatus."');</script>";
}
mysqli_free_result($result);
}
//SECOND SQL QUERY
$sql = "SELECT botwins, playerwins FROM game WHERE id=$id;";
if($result = mysqli_query($conn, $sql))
{
echo "success"; //To test if the $result is not false (its returning false).
while($row = mysqli_fetch_row($result)) //I also tried mysqli_fetch_assoc but it didn't work.
{
if($row[0] >= 10 || $row[1] >= 10){
$sql = "call resetgame($id);";
mysqli_query($conn, $sql);
}
}
mysqli_free_result($result);
}
When I removed the first query and left the second, the second worked just fine. Why can't I put them together?
I am not getting any errors, but I am not getting any results from the second query either.