title: mySQL and PHP login page problems
body: <p>I have been trying to make this login form. All the mySQL is correct and it is connecting to the database, log in details are there and are correct when inputting however I get an error from PHP and the message that my log in details are wrong. I'm new to PHP/mySQL so I don't really know what I am doing wrong! </p>
  
  <p><a href="http://pastebin.com/DQmF30JM" rel="nofollow">Code for the page that connects to the database.</a> </p>
  
  <blockquote>
    <p>Error from PHP: Warning: mysql_num_rows() expects parameter 1 to be resource, null given in /home/bluecode/public_html/intranet/checklogin.php on line 22 </p>
  </blockquote>
  
  <p>The variables from the form are myusername and mypassword. </p>
  
  <p>Thanks :) </p>
  
  <pre><code>&lt;?php
  
  
  // username and password sent from form
  $username=stripslashes($_POST['myusername']);
  $password=sha1(stripslashes($_POST['mypassword']));
  
  
  $host="localhost"; // Host name
  $username="bluecode_power"; // Mysql username
  $password="bluecode123"; // Mysql password
  $db_name="bluecode_login"; // Database name
  $tbl_name="members"; // Table name
  
  // Connect to server and select databse.
  mysql_connect("$id", "$username", "$password")or die("cannot connect");
  mysql_select_db("$db_name")or die("cannot select databse");
  
  $sql="SELECT * FROM `members` WHERE myusername=='$username' and mypassword=='$password'";
  
  // Mysql_num_row is counting table row
  $count=mysql_num_rows($result);
  
  
  if($myusername == admin){
  session_register("myusername");
  session_register("mypassword");
  header("location:login_success.php");
  }
  
  // If result matched $myusername and $mypassword, table row must be 1 row
  if($count==1){
  
  
  
  // Register $myusername, $mypassword and redirect to file "login_success.php"
  session_register("myusername");
  session_register("mypassword");
  header("location:login_success.php");
  }
  
  else {
  echo "Wrong Username or Password";
  }
  ?&gt;
  </code></pre>