title: PHP Fatal error: Call to a member function bind_param() on a non-object (PHP-MySQL PreparedStatement)
body: <p>I know this has been asked several times here but I assure you i tried every suggestion but that didn't help me. (I guess because this error is caused by a wide number of factors).</p>
  
  <p>Here is my code:</p>
  
  <pre><code>$stmt = $conn-&gt;prepare("INSERT INTO User (Username, Password, Email, Race) VALUES (?, ?, ?, ?)");
          $stmt-&gt;bind_param("ssss", $Username, $Password, $Email, $Race);
  
      if($stmt-&gt;execute())
      {
          $stmt = $conn-&gt;prepare("SELECT Id FROM User WHERE Username=?");
      if ($stmt === FALSE)
      {
          echo ($this-&gt;conn-&gt;error);
      }
          $stmt-&gt;bind_param("s", $Username);
          if($stmt -&gt; execute())
          {
              $stmt -&gt; bind_result($idd);
              $stmt -&gt; fetch();
              echo $idd;
              $acre=1000;
              $alertlevel=0;
              $offperc=0;
              $deffperc=0;
              $userlevel=1;
              $upgradeavail=0;
  
              $stmt = $conn-&gt;prepare("INSERT INTO Info (idd, acre, alertlevel, offperc, deffperc, userlevel, upgradeavail) VALUES (?, ?, ?, ?, ?, ?, ?)");
              $stmt-&gt;bind_param("iiiiiii", $idd, $acre, $alertlevel, $offperc, $deffperc, $userlevel, $upgradeavail);
  
              if($stmt -&gt; execute())
              {
                  echo "";
              }
              else
              {
                  echo "false";
              }
          }
          else
          {
              echo "false";
          }
      }
      else
      {
          echo "false";
      }
  </code></pre>
  
  <p>and that is my SQL table:</p>
  
  <blockquote>
    <p>Table User:  Id*(int and primary)*    Username*(varchar)*
      Password*(varchar)*     Email*(varchar)*    Age*(int)*</p>
    
    <p>Table Info: IdPrimary*(int and primary)* idd*(int)*  acre*(int)* 
    alertlevel*(int)*  offperc*(int)*  deffperc*(int)*  userlevel*(int)*
    upgradeavail*(int)*</p>
  </blockquote>
  
  <p>the one giving me the error is located on line 57 which is: </p>
  
  <pre><code>$stmt-&gt;bind_param("iiiiiii", $idd, $acre, $alertlevel, $offperc, $deffperc, $userlevel, $upgradeavail);
  </code></pre>
  
  <p>I used this to make sure that the select prepare is working and indeed it is.</p>
  
  <pre><code>if ($stmt === FALSE)
  {
      echo ($this-&gt;conn-&gt;error);
  }
  </code></pre>
  
  <p>this shows me that indeed it was able to fetch the Id from table User </p>
  
  <pre><code>  echo $idd; 
  </code></pre>
  
  <p>Sorry for the long article but I wanted to give you all the possible details :)
  Thanks for the help!</p>