title: Multiple prepared statements on same page MYSQLI
body: <p>I have some issues with my code. It seems like I'm not able to have multiple prepared statements which seems a little unusual to me.</p>
  
  <p>I would be glad if you can spot an error or help me because I can't figure out the issue.</p>
  
  <p>My error:</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function bind_param() on boolean in /Applications/XAMPP/xamppfiles/htdocs/platform/creating_user.php on line 37</p>
  </blockquote>
  
  <p>I am trying to check if the users email already exists in the database and then register the user.</p>
  
  <p>The code works fine when i dont execute the $check.</p>
  
  <pre><code>$check-&gt;execute();
  </code></pre>
  
  <p>I would also like some response on my workflow (the way my code is built up). is it okay? </p>
  
  <p>Thanks!</p>
  
  <pre><code>&lt;?php 
  
  
  $db = new mysqli("localhost","root","","database");
  session_start();
  
  
  if (isset($_POST)){ 
      if(
          !empty($_POST["name"]) 
        &amp; !empty($_POST["city"]) 
        &amp; !empty($_POST["zip"]) 
        &amp; !empty($_POST["email"]) 
        &amp; !empty($_POST["tel"]) 
        &amp; !empty($_POST["password"])
      ) {
  
          $name       = encrypt($_POST["name"]);
          $city       = encrypt($_POST["city"]);
          $zip        = encrypt($_POST["zip"]);
          $email      = encrypt($_POST["email"]);
          $tel        = encrypt($_POST["tel"]);
          $password   = encrypt($_POST["password"]);
  
  
          if(!empty($name) &amp;&amp; !empty($city) &amp;&amp; !empty($zip) &amp;&amp; !empty($email) &amp;&amp; !empty($tel) &amp;&amp; !empty($password)) {
  
              $check = $db-&gt;prepare("SELECT email FROM user WHERE email = ?");
              $check-&gt;bind_param('s', $email); 
              $check-&gt;execute();
  
              if ($check-&gt;num_rows == 1) {  
                  header("Location: index.php");
                  die();
              } else {
  
  
              $insert = $db-&gt;prepare("INSERT INTO user (name, city, zip, email, tel, password, created) VALUES (?, ?, ?, ?, ?, ?, NOW())");
              $insert-&gt;bind_param("ssssss",$name, $city, $zip, $email, $tel, $password);
  
  
              if ($insert-&gt;execute()){ 
  
                  $db-&gt;close();
                  $_SESSION["user"] = $email;
                  header("Location: created_user");
                  die();
  
              } else {
                  header("Location: create-user");
                  die();
              }
  
          }
  
          } else {
              header("Location: create-user");
              die();
          }
  
  
      } else {
          header("Location: create-user");
          die();
      }
  } else {
      header("Location: create-user");
      die();
  } 
  
  
  ?&gt;
  </code></pre>