title: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/digibeem/public_html/forgot_pass.php on line 55
body: <p>This is my coding: of forgot_pass.php</p>
  
  <pre><code>&lt;?php
  include_once("php_includes/check_login_status.php");
  // If user is already logged in, header that weenis away
  if($user_ok == true){
      header("location: user.php?u=".$_SESSION["username"]);
      exit();
  }
  ?&gt;&lt;?php
  // AJAX CALLS THIS CODE TO EXECUTE
  if(isset($_POST["e"])){
      $e = mysqli_real_escape_string($db_conx, $_POST['e']);
      $sql = "SELECT id, username FROM users WHERE email='$e' AND activated='1' LIMIT 1";
      $query = mysqli_query($db_conx, $sql);
      $numrows = mysqli_num_rows($query);
      if($numrows &gt; 0){
          while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){
              $id = $row["id"];
              $u = $row["username"];
          }
          $emailcut = substr($e, 0, 4);
          $randNum = rand(10000,99999);
          $tempPass = "$emailcut$randNum";
          $hashTempPass = md5($tempPass);
          $sql = "UPDATE useroptions SET temp_pass='$hashTempPass' WHERE username='$u' LIMIT 1";
          $query = mysqli_query($db_conx, $sql);
          $to = "$e";
          $from = "auto_responder@digibeem.com";
          $headers ="From: $from\n";
          $headers .= "MIME-Version: 1.0\n";
          $headers .= "Content-type: text/html; charset=iso-8859-1 \n";
          $subject ="DigiBeem Account Temporary Password Request";
          $msg = '&lt;h2&gt;Hello '.$u.'&lt;/h2&gt;&lt;p&gt;This is an automated message from digibeem. If you did not recently initiate the Forgot Password process, please disregard this email.&lt;/p&gt;&lt;p&gt;You indicated that you forgot your login password. We can generate a temporary password for you to log in with, then once logged in you can change your password to anything you like.&lt;/p&gt;&lt;p&gt;After you click the link below your password to login will be:&lt;br /&gt;&lt;b&gt;'.$tempPass.'&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.digibeem.com/forgot_pass.php?u='.$u.'&amp;p='.$hashTempPass.'"&gt;Click here now to apply the temporary password shown below to your account&lt;/a&gt;&lt;/p&gt;&lt;p&gt;If you do not click the link in this email, no changes will be made to your account. In order to set your login password to the temporary password you must click the link above.&lt;/p&gt;';
          if(mail($to,$subject,$msg,$headers)) {
              echo "success";
              exit();
          } else {
              echo "email_send_failed";
              exit();
          }
      } else {
          echo "no_exist";
      }
      exit();
  }
  ?&gt;&lt;?php
  // EMAIL LINK CLICK CALLS THIS CODE TO EXECUTE
  if(isset($_GET['u']) &amp;&amp; isset($_GET['p'])){
      $u = preg_replace('#[^a-z0-9]#i', '', $_GET['u']);
      $temppasshash = preg_replace('#[^a-z0-9]#i', '', $_GET['p']);
      if(strlen($temppasshash) &lt; 10){
          exit();
      }
      $sql = "SELECT id FROM useroptions WHERE username='$u' AND temp_pass='$temppasshash' LIMIT 1";
      $query = mysqli_query($db_conx, $sql);
      $numrows = mysqli_num_rows($query);
      if($numrows == 0){
          header("location: message.php?msg=There is no match for that username with that temporary password in the system. We cannot proceed.");
          exit();
      } else {
          $row = mysqli_fetch_row($query);
          $id = $row[0];
          $sql = "UPDATE users SET password='$temppasshash' WHERE id='$id' AND username='$u' LIMIT 1";
          $query = mysqli_query($db_conx, $sql);
          $sql = "UPDATE useroptions SET temp_pass='' WHERE username='$u' LIMIT 1";
          $query = mysqli_query($db_conx, $sql);
          header("location: login.php");
          exit();
      }
  }
  ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;  
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  
      &lt;title&gt;Password Recovery&lt;/title&gt;
  
          &lt;!-- CSS --&gt;
          &lt;link rel="stylesheet" href="css/style.css" type="text/css" media="screen" /&gt;
          &lt;!--[if IE 6]&gt;
              &lt;link rel="stylesheet" type="text/css" media="screen" href="css/ie-hacks.css" /&gt;
              &lt;script type="text/javascript" src="js/DD_belatedPNG.js"&gt;&lt;/script&gt;
              &lt;script&gt;
                  /* EXAMPLE */
                  DD_belatedPNG.fix('*');
              &lt;/script&gt;
          &lt;![endif]--&gt;
          &lt;!--[if IE 7]&gt;
              &lt;link rel="stylesheet" href="css/ie7-hacks.css" type="text/css" media="screen" /&gt;
          &lt;![endif]--&gt;
          &lt;!--[if IE 8]&gt;
              &lt;link rel="stylesheet" href="css/ie8-hacks.css" type="text/css" media="screen" /&gt;
          &lt;![endif]--&gt;
          &lt;!-- ENDS CSS --&gt;
  
          &lt;!-- prettyPhoto --&gt;
          &lt;link rel="stylesheet" href="js/prettyPhoto/css/prettyPhoto.css" type="text/css" media="screen" /&gt;
          &lt;!-- ENDS prettyPhoto --&gt;
  
          &lt;!-- JS --&gt;
          &lt;script type="text/javascript" src="js/jquery_1.4.2.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="js/jqueryui.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="js/easing.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="js/jquery.cycle.all.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="js/tooltip/jquery.tools.min.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="js/filterable.pack.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="js/prettyPhoto/js/jquery.prettyPhoto.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="js/chirp.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="js/jquery.tabs/jquery.tabs.pack.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="js/custom.js"&gt;&lt;/script&gt;
          &lt;!-- ENDS JS --&gt;
  
          &lt;!-- Cufon --&gt;
          &lt;script src="js/cufon-yui.js" type="text/javascript"&gt;&lt;/script&gt;
          &lt;script src="js/fonts/bebas-neue_400.font.js" type="text/javascript"&gt;&lt;/script&gt;
          &lt;!-- /Cufon --&gt;
  
          &lt;!-- superfish --&gt;
          &lt;link rel="stylesheet" type="text/css" media="screen" href="css/superfish-custom.css" /&gt; 
          &lt;script type="text/javascript" src="js/superfish-1.4.8/js/hoverIntent.js"&gt;&lt;/script&gt; 
          &lt;script type="text/javascript" src="js/superfish-1.4.8/js/superfish.js"&gt;&lt;/script&gt; 
          &lt;!-- ENDS superfish --&gt;
  
          &lt;!-- tabs --&gt;
          &lt;link rel="stylesheet" href="css/jquery.tabs.css" type="text/css" media="print, projection, screen" /&gt;
          &lt;!-- Additional IE/Win specific style sheet (Conditional Comments) --&gt;
          &lt;!--[if lte IE 7]&gt;
          &lt;link rel="stylesheet" href="css/jquery.tabs-ie.css" type="text/css" media="projection, screen"&gt;
          &lt;![endif]--&gt;
          &lt;!-- ENDS tabs --&gt;
      &lt;style type="text/css"&gt;
  #forgotpassform{
      margin-top:24px;    
  }
  #forgotpassform &gt; div {
      margin-top: 12px;   
  }
  #forgotpassform &gt; input {
      width: 250px;
      padding: 3px;
      background: #F3F9DD;
  }
  #forgotpassbtn {
      font-size:15px;
      padding: 10px;
  }
  &lt;/style&gt;
  &lt;script src="js/main.js"&gt;&lt;/script&gt;
  &lt;script src="js/ajax.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  function forgotpass(){
      var e = _("email").value;
      if(e == ""){
          _("status").innerHTML = "Type in your email address";
      } else {
          _("forgotpassbtn").style.display = "none";
          _("status").innerHTML = 'please wait ...';
          var ajax = ajaxObj("POST", "forgot_pass.php");
          ajax.onreadystatechange = function() {
              if(ajaxReturn(ajax) == true) {
                  var response = ajax.responseText;
                  if(response == "success"){
                      _("forgotpassform").innerHTML = '&lt;h3&gt;Step 2. Check your email inbox in a few minutes&lt;/h3&gt;&lt;p&gt;You can close this window or tab if you like.&lt;/p&gt;';
                  } else if (response == "no_exist"){
                      _("status").innerHTML = "Sorry that email address is not in our system";
                  } else if(response == "email_send_failed"){
                      _("status").innerHTML = "Mail function failed to execute";
                  } else {
                      _("status").innerHTML = "An unknown error occurred";
                  }
              }
          }
          ajax.send("e="+e);
      }
  }
  &lt;/script&gt;
      &lt;/head&gt;
  
  
      &lt;body&gt;
  
          &lt;!-- HEADER --&gt;&lt;?php include 'header.php'  ?&gt;&lt;!-- ENDS HEADER --&gt;
  
          &lt;!-- MAIN --&gt;
          &lt;div id="main"&gt;
  
              &lt;!-- wrapper --&gt;
              &lt;div class="wrapper"&gt;
  
                  &lt;!-- content --&gt;
                  &lt;div class="content"&gt;
          &lt;div class="title-holder"&gt;
                          &lt;span class="title"&gt;&lt;h2&gt;Password Recovery Corner...&lt;/h2&gt;&lt;/span&gt;
                          &lt;span class="subtitle"&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;                   &lt;/div&gt;
                          &lt;!-- POSTS --&gt;
                          &lt;div align="center"&gt;
    &lt;h3&gt;Generate a temorary log in password&lt;/h3&gt;
    &lt;form id="forgotpassform" onsubmit="return false;"&gt;
      &lt;div&gt;Step 1: Enter Your Email Address&lt;/div&gt;
      &lt;input id="email" type="text" onfocus="_('status').innerHTML='';" maxlength="88"&gt;
      &lt;br /&gt;&lt;br /&gt;
      &lt;button id="forgotpassbtn" onclick="forgotpass()"&gt;Generate Temporary Log In Password&lt;/button&gt; 
      &lt;p id="status"&gt;&lt;/p&gt;
    &lt;/form&gt;
  &lt;/div&gt;
                          &lt;!-- ENDS POSTS --&gt;
  
                          &lt;!-- sidebar --&gt;
  
                          &lt;!-- ENDS sidebar --&gt;
  
  
                  &lt;/div&gt;
                  &lt;!-- ENDS content-blog --&gt;
  
                  &lt;div class="shadow-divider"&gt;&lt;/div&gt;
              &lt;/div&gt;
              &lt;!-- ENDS main-wrapper --&gt;
  
  
          &lt;/div&gt;      
          &lt;!-- ENDS MAIN --&gt;  
  
  &lt;?php include 'footer_social.php' ?&gt;
  
          &lt;!-- start cufon --&gt;
          &lt;script type="text/javascript"&gt; Cufon.now(); &lt;/script&gt;
          &lt;!-- ENDS start cufon --&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The above coding is coding for forgot password system, what i was trying but got failed. And this is line no. 55, Please tell me how to make this working, as i am really very troubled with this problem, Please Please Please and if possible then would you please suggest me changes including either row no. or some text in row.</p>
  
  <pre><code>$numrows = mysqli_num_rows($query);
  </code></pre>