title: Fatal error on a non-object
body: <p>Hey, so I have created a function to check the DB for unique entries, but when I call the function it doesn't seem to work and gives me a fatal error any ideas ? Thanks :)       </p>
  
  <pre><code> //Check for unique entries
      function checkUnique($table, $field, $compared)
      {
          $query = $mysqli-&gt;query('SELECT  '.$mysqli-&gt;real_escape_string($field).' FROM '.$mysqli-&gt;real_escape_string($table).' WHERE "'.$mysqli-&gt;real_escape_string($field).'" = "'.$mysqli-&gt;real_escape_string($compared).'"');
          if(!$query){ 
              return TRUE; 
          }   
          else {
              return FALSE;
          }
      }
  </code></pre>
  
  <p>The page calling it.....</p>
  
  <pre><code>    //Start session
  session_start();
  
  //Check if the session is already set, if so re-direct to the game
  if(isset($_SESSION['id'], $_SESSION['logged_in'])){
      Header('Location: ../main/index.php');
  };
  
  //Require database connection
  require_once('../global/includes/db.php');
  require_once('../global/functions/functions.php');
  
  //Check if the form has been submitted
  if (isset($_POST['signup'])){
      //Validate input
      if (!empty($_POST['username']) &amp;&amp; !empty($_POST['password']) &amp;&amp; $_POST['password']==$_POST['password_confirm'] &amp;&amp; !empty($_POST['email']) &amp;&amp; validateEmail($_POST['email']) == TRUE &amp;&amp; checkUnique('users', 'email', $_POST['email']) == TRUE &amp;&amp; checkUnique('users', 'username', $_POST['username']) == TRUE)
      {
          //Insert user to the database
          $insert_user = $mysqli-&gt;query('INSERT INTO (`username, `password`, `email`, `verification_key`) VALUES ("'.$mysqli-&gt;real_escape_string($_POST['username']).'", "'.$mysqli-real_escape_string(md5($_POST['password'])).'", "'.$mysqli-&gt;real_escape_string($_POST['email']).'", "'.randomString('alnum', 32). '"') or die($mysqli-&gt;error());
  
          //Get user information
          $getUser = $mysqli-&gt;query('SELECT id, username, email, verification_key FROM users WHERE username = "'.$mysqli-&gt;real_escape_string($_POST['username']).'"' or die($mysqli-&gt;error()));
  
          //Check if the $getUser returns true
          if ($getUser-&gt;num_rows == 1)
          {
              //Fetch associated fields to this user
              $row = $getUser-&gt;fetch_assoc();
  
              //Set mail() variables
              $headers = 'From: no-reply@musicbattles.net'."\r\n".
                        'Reply-To: no-reply@musicbattles.net'."\r\n".
                        'X-Mailer:  PHP/'.phpversion();
              $subject = 'Activate your account (Music Battles.net)';
              //Set verification email message
              $message = 'Dear '.$row['username'].', I would like to welcome you to Music Battles. Although in order to enjoy the gmae you must first activate your account. \n\n Click the following link: http://www.musicbattles.net/home/confirm.php?id='.$row['id'].'key='.$row['verification_key'].'\n Thanks for signing up, enjoy the game! \n Music Battles Team';
  
              //Attempts to send the email
              if (mail($row['email'], $subject, $message, $headers))
              {
                  $msg = '&lt;p class="success"&gt;Accound has been created, please go activate it from your email.&lt;/p&gt;';
              }
              else {
                  $error = '&lt;p class="error"&gt;The account was created but your email was not sent.&lt;/p&gt;';
              }
          }
              else {
                  $error = '&lt;p class="error"&gt;Your account was not created.&lt;/p&gt;';
              }
          }
              else {
                  $error = '&lt;p class="error"&gt;One or more fields contain non or invalid data.&lt;/p&gt;';
              }
          }
  </code></pre>
  
  <p>Erorr....</p>
  
  <pre><code>Fatal error: Call to a member function query() on a non-object in /home/mbattles/public_html/global/functions/functions.php on line 5
  </code></pre>