Yep. You are wrong in writing the query.
<?
$host = "localhost";
$user = "myuser";
$pass = "mypassword";
$dbname = "voters";
$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
$dbname = "voters";
mysql_select_db($dbname);
$lname=$_POST['lname'];
$fname=$_POST['fname'];
$dob=$_POST['dob'];
$query= "select * from voters where lname='$lname' AND
fname='$fname' AND dob='$dob'";
echo $query;
$result= mysql_query($query);
$num_results = mysql_num_rows($result);
while ($row = mysql_fetch_array($result)) {
echo "<p>",$row['lname'], ": ",$row['fname'], ": ",$row['dob'];
}
?>
Check this. Don't you think this is much easier than using $_POST in your query ? I do it this way. I first assign the values of the $_POST to a php variable, then use that php variable(in this case, $fname,$lname and $dob). And, you shouldn't end your query (with a semicolon) after every condition.