-1
<?php
      $query=("SELECT  exam_ID, question, choice1, choice2, choice3,answer FROM exams ORDER BY RAND() LIMIT 5 " );
      $result = @mysqli_query ($con, $query); // Run the query.
      while($row =mysqli_fetch_array($result,MYSQLI_BOTH)): 

      ?>

this is code is to help from get questions from my exams database but anytime i get this error

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\Login\question.php on line 29

Qirel
  • 23,315
  • 7
  • 41
  • 57

1 Answers1

-1

You have to initialize the $con variable with the mysqli_connect before running the query.

mysqli_connect php manual

Juan
  • 5,420
  • 2
  • 14
  • 26