title: mysql and php login page with mysql_num_rows
body: <p>I have those codes and its give me an error 'Warning: mysql_num_rows() expects parameter 1 to be resource' :</p>
  
  <p>PHP:</p>
  
  <pre><code>&lt;?php
  @error_reporting(0);
  @session_start();
  @include("sql.php");
  $log_error = "";
  
  if(isset($_POST['send'])) {
  $user = protect($_POST['username']);
  $pass = protect($_POST['password']);
  $q = mysql_query("SELECT * FROM login WHERE name = '".$user."' and pass = '".$pass."'",$sqlc);
  $count = mysql_num_rows($q);
  
  if($count &gt; 0) {
      $_SESSION['username'] == $user;
      header('Location: index.php');
      $log_error = "0";
  } else {
      $log_error = "1";
  }
  }
  ?&gt;
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;table border="0"&gt;
          &lt;form action="" method="post"&gt;
              &lt;tr&gt;
                  &lt;td colspan="2" style="width:100%;"&gt;&lt;span&gt;Login&lt;/span&gt;&lt;/td&gt;
              &lt;tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Username:&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="username" value="" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Password:&lt;/td&gt;
                  &lt;td&gt;&lt;input type="password" name="password" value="" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td colspan="2" style="width:100%;"&gt;&lt;input type="submit" name="send" value="Login" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;/form&gt;
          &lt;/table&gt;
  </code></pre>
  
  <p>And the SQL connection (sql.php):</p>
  
  <pre><code>&lt;?php
  $Host = 'localhost';
  $User = 'dash_sys1';
  $Pass = '123456Ben';
  $DB = 'dash_sys1';
  
  $sqlc = mysql_connect($Host,$User,$Pass) or die(mysql_error());
  mysql_select_db($DB) or die(mysql_error());
  function protect($str) {
  return htmlspecialchars(mysql_real_escape_string(trim($str)));
  }
  ?&gt;
  </code></pre>
  
  <p>its gives me that error:  Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\cms\admin\login.php on line 11</p>
  
  <p>what I did wrong? </p>