title: PHP MYSQL Warning: mysql_query() expects parameter 1 to be string, resource given in
body: <pre><code>&lt;?php
      include 'connect.php';
      include 'header.php';
      
      $page = &quot;signup.php&quot;;
      // receive the invite code:
      $code = $_POST['code'];
      $sql = &quot;SELECT codes FROM invites WHERE codes='$code'&quot;;
      // check the table for matching codes
      $result = mysql_query($sql);
      // check if the request returned 1 or 0 rows from the database
      if (mysql_query($result)) {
          // end any previously defined sessions.
          session_start();session_unset();session_destroy();
          // start a new session
          session_start();
          // define the session variable.
          // this allows us to check if it's set later and is required for
          // the script to run properly.
          $code = $_POST[&quot;code&quot;];
          mysql_query(&quot;DELETE FROM invites WHERE codes='$code'&quot;);
          header('Location: '.$page);
          exit;
      } else {
          echo &quot;Invite invalid. Please try again later.&quot;;
          echo $code;
      }
      
      include 'footer.php';
  ?&gt;
  </code></pre>
  <p>I am trying to implement an invite system to a webpage I am working on. However when trying to evaluate if there is a row containing the invite code I keep either getting nothing or this warning. The warning in this case but if I change the if state to ==1, it allows everyone regardless of code and ==0 does throws different errors.</p>