$sql = "select sum(case when 'Social Media Opinion'='I like social media.' and 'Social Media Usage'='Every day' then 1 else 0 end) as ye from svar2;";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
echo "<thead>";
echo "<tr>";
echo "<td>Internet Fatigue out of 10</td>";
echo "</tr>";
echo "<thead>";
if ($resultCheck > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<tbody>";
echo "<tr>";
echo"<td>". $row['ye']. "</td>";
echo "</tr>";
echo "</tbody>";
}
}
This code will find out the number of people who answered "I use social media everyday" and "I like social media." I am trying to run this code which finds the sum of people who have answered specific answers to both questions. When I run it in PHP my admin, it works fine, but when I run it in my PHP website, it errors with
Fatal error: Uncaught TypeError: mysqli_num_rows(): Argument #1 ($result) must be of type mysqli_result, bool given in C:\xampp\htdocs\SPU\index.php:140 Stack trace: #0 C:\xampp\htdocs\SPU\index.php(140): mysqli_num_rows(false) #1 {main} thrown in C:\xampp\htdocs\SPU\index.php on line 140
please help