title: mysql_query() expects parameter 1 to be string, resource given
body: <p>so my code is this..</p>
  
  <pre><code>&lt;?php
  
  $password=(!isset($_POST['password']));
  $username=(!isset($_POST['username']));
  
      $username = mysql_real_escape_string($username);
      $password = mysql_real_escape_string($password);
  
  $query = mysql_query ("SELECT * FROM tb_funcionario WHERE username='$username' and password='$password'");
  
     $result = mysql_query($query);
  
     var_dump($result);
  
     $num_rows = $result-&gt;$num_rows;
  
      if ($num_rows)
      {
          echo "username already exist";
      }
      else
      {
       $query = "INSERT INTO tb_funcionario (nome_funcionario, username, password) VALUES (
      '$_POST[nome_funcionario]',
      '$_POST[username]',
      '$_POST[password]'
      )";;
  
         $result = mysql_query($query) or die (mysql_error());
  
      }
  
  
          mysql_query($query);
          mysql_close($bd_con);
  ?&gt;
  </code></pre>
  
  <p>And its always giving me the "mysql_query() expects parameter 1 to be string, resource given" and i cant figure out how to solve it.</p>
  
  <p>Can yall help me?</p>