title: Fatal error: Call to undefined method mysqli_result::fetch() in C:\wamp\www\...... on line 12
body: <p>I'm trying to test my login page, thus when I log in it should redirect to my account page, but I get this error</p>
  
  <blockquote>
    <p>Fatal error: Call to undefined method mysqli_result::fetch() in C:\wamp\www...... on line 12</p>
  </blockquote>
  
  <p>here is my source code for the Login.php page</p>
  
  <pre><code>&lt;?php require ("connections/Connection.php"); ?&gt;
  &lt;?php 
  
  if(isset($_POST['Login_Button'])) {
  
      session_start();
      $Email = $_POST['Email'];
      $Password = $_POST['Password'];
  
  $result = $Conn-&gt;query("Select UserID FROM users WHERE Email='$Email' AND Password='$Password'");
  
      while ($num_rows = $result-&gt;fetch(MYSQLI_BOTH));
  
  {
  
  session_start();
  
      $_SESSION["UserID"] = $num_rows['UserID'];
  
          header('Location: Account.php');
  
      }
  }
  ?&gt;
  
  &lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;link href="assets/css/Master.css" rel="stylesheet" type="text/css" /&gt;
  &lt;link href="assets/css/Menu.css" rel="stylesheet" type="text/css" /&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Template&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;div class="Container"&gt;
      &lt;div class="Header"&gt;&lt;/div&gt;
      &lt;div class="Menu"&gt;
          &lt;div id="Menu"&gt;
              &lt;nav&gt;
                  &lt;ul class="cssmenu"&gt;
                      &lt;li&gt;&lt;a href="#"&gt;Register&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="#"&gt;LogIn&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/nav&gt;
          &lt;/div&gt; 
  &lt;/div&gt;
    &lt;div class="LeftBody"&gt;&lt;/div&gt;
      &lt;div class="RightBody"&gt;
              &lt;form action="" method="post" name="LoginForm" id="LoginForm"&gt;
                  &lt;div class="FormElement"&gt; &lt;input name="Email" type="email" required="required" class="TField" id="Email" placeholder="Email"&gt; &lt;/div&gt;
                  &lt;div class="FormElement"&gt; &lt;input name="Password" type="password" required="required" class="TField" id="Password" placeholder="Password"&gt; &lt;/div&gt;                
                  &lt;div class="FormElement"&gt; &lt;input name="Login_Button" type="submit" class="button" id="Login_Button" value="Login"&gt; &lt;/div&gt;
        &lt;/form&gt;
      &lt;/div&gt;
      &lt;div class="Footer"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <h1>    </h1>
  
  <h1>Here is my connection.php (Mysqli connect code)</h1>
  
  <pre><code>&lt;?php 
  
  $dbhost = "localhost";
  $dbuser = "root";
  $dbpass = "";
  $dberror1 = "Could Not Connect to Your Database";
  $dberror2 = "Could Not Find Your Table";
  
  $Conn = mysqli_connect($dbhost, $dbuser, $dbpass) or die ($dberror1);
  
  $Select_db = mysqli_select_db($Conn, 'users') or die ($dberror2);
  
  $query = mysqli_query($Conn, "Select * FROM users");
  
  $num_rows = mysqli_num_rows($query);
  
  if($num_rows != 0){
  
  while ($fetch = mysqli_fetch_assoc($query)){
  
  echo $fetch['UserID'];
  }
  }
  
  ?&gt;
  </code></pre>
  
  <p>Can someone help?</p>