Code:
<?php
$con = mysql_connect("localhost","peter","abc123");
$username = "riddle";
$password = "1234";
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_db", $con);

$result = mysql_query("SELECT * FROM AccountsTable WHERE username=" . $username);

while($row = mysql_fetch_array($result))
  {
  if (row['password'] == $password) echo "Correct password!";
  }

mysql_close($con);
?>
That looks right. Took example from PHP MySQL Where Clause and edited a few things.