title: Check SQL database if value exists and then return value if it does
body: <p>I am pretty new to both php and SQL.  I have a login page where I ask for the users username and password.  I would like to search a database I have created for both the username and password to see if they exist.  The database table has two columns, Username and Password.  I don't care to much about security so a simple script will work. But I do want to be able to expand on it someday, so therefor I am using a database, because currently I just use an array in php to store usernames and passwords.  </p>
  
  <p>I am currently trying to get this code to work but am not getting the results I need.  </p>
  
  <pre><code>$user_name = "db_username";
  $password = "db_password";
  $database = "db_name";
  $server = "db_server";
  
  
  
  $db_handle = mysql_connect($server, $user_name, $password);
  $db_found = mysql_select_db($database, $db_handle);
  
  if ($db_found) {
  $result =mysql_query("SELECT 1 FROM my_table WHERE Username = $username");
  if ($result&gt;0)
  
      {
          echo 'Username and Password Found'; 
      }
  else
      {
      echo 'Username and Password NOT Found';
      }
  }
  else {
  print "Database NOT Found.";
  mysql_close($db_handle);
  }
  </code></pre>
  
  <p>This always returns <code>Username and Password Found</code> no matter is the username is in there or not. When printing <code>$result</code> I get <code>Resource id #2</code>.  Thank you </p>