i got this error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\db.php on line 13
my php code is this:
<?php
//Database Info
$dbhost="localhost";
$dbuser="root";
$dbpass="something";
$dbname="somedb";
$table="users";
//Connect to Database
$con=mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname, $con);
$user=$_POST['user'];
$pass=$_POST['pass'];
$query = "SELECT * FROM $table WHERE Username=$user AND Password=$pass";//MySQL Query
$result=mysql_query($query, $con);//Line 13 ERROR
$numresults=mysql_num_rows($result);//Check The Number Of Results
if($numresults == 1)
{
$handle=fopen("boxsite.html", "a+");
$contents=fread($handle, filesize("boxsite.html"));
fclose($handle);
echo $contents;
}
else
{
$handle=fopen("LoginFail.html", "r");
$contents=fread($handle, filesize("LoginFail.html"));
fclose($handle);
echo $contents;
}
?>
i searched numerous times but i can't find what's wrong with my query. plz help me