title: mysqli_stmt_close() expects to be parameter 1
body: <p>I've been coding in <code>PHP</code> and connecting it up to <code>MySql</code>. I keep on getting an error</p>
  
  <blockquote>
    <p>Warning: mysqli_stmt_close() expects parameter 1 to be <code>mysqli_stmt</code>, boolean given in C:\xampp\htdocs\xxxx on line 175</p>
  </blockquote>
  
  <p>Is there anything wrong with this block of code?</p>
  
  <pre><code> if(empty(trim($_POST['dept'])) &amp;&amp; empty(trim($_POST['fname'])) &amp;&amp; empty(trim($_POST['lname'])) &amp;&amp; empty(trim($_POST['email'])) &amp;&amp; empty(trim($_POST['cnum'])) &amp;&amp; empty(trim($_POST['dob'])) &amp;&amp; empty(trim($_POST['gender'])) &amp;&amp; empty(trim($_POST['minitial'])) &amp;&amp; strlen(trim($_POST['minitial'])) &gt; 1   ){
              $regerr = "Please complete your information";
          }else{
              $fname = trim($_POST['fname']);
              $lname = trim($_POST['lname']);
              $email = trim($_POST['email']);
              $cnum = trim($_POST['cnum']);
              $dob = trim($_POST['dob']);
              $gender = trim($_POST['gender']);
              $dept = trim($_POST['dept']);
              $minitial = trim($_POST['minitial']);
          }
  
          // Check input errors before inserting in database
          if(empty($usernameerr) &amp;&amp; empty($passworderr) &amp;&amp; empty($confirmpassworderr) &amp;&amp; empty($regerr) ){
  
              // Prepare an insert statement
              $sql = "INSERT INTO login_info (username, password) VALUES (?, ?);
                      INSERT INTO user_info (fname, sname, minitial, contact_num, gender, dob, department) VALUES (?,?,?,?,?,CAST (? AS DATE),?);";
  
              if($stmt = mysqli_prepare($link, $sql)){
                  // Bind variables to the prepared statement as parameters
                  mysqli_stmt_bind_param($stmt, "sssssssss", $param_username, $param_password, $param_fname, $param_sname, $param_minitial, $param_cnum, $param_gender, $param_dob, $param_department);
  
                  // Set parameters
                  $param_username = $username;
                  $param_password = password_hash($password, PASSWORD_DEFAULT); // Creates a password hash
                  $param_fname = $fname;
                  $param_sname = $lname;
                  $param_minitial =$minitial;
                  $param_cnum = $cnum;
                  $param_gender = $gender;
                  $param_dob = $dob;
                  $param_department = $dept;
  
                  // Attempt to execute the prepared statement
                  if(mysqli_stmt_execute($stmt)){
  
                      session_start();
                      $_SESSION['username'] = $username;
                      $_SESSION['usernumber'] = $mysqli_insert_id($link);
                      header("location: home-trabawho.php");
                  } else{
                      echo "Something went wrong. Please try again later.";
                  }
              }
  
              // Close statement
              mysqli_stmt_close($stmt);
          }
  </code></pre>