am geting this error while testing the login panel of my website that am currently developing.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/smartie1/public_html/checklog.php on line 43 which is in red

this is the php script used for login

 function session_defaults() {
$_SESSION['logged'] = false;
$_SESSION['uid'] = 0;
$_SESSION['username'] = '';
$_SESSION['cookie'] = 0;
$_SESSION['remember'] = false;

if (!isset($_SESSION['uid']) ) {

$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="XXXXXX[CODE][/CODE]"; // Database name
$tbl_name="Customer_Infor"; // Table name
// Connect to server and select databse.
$con = mysql_connect("localhost","XXXXXX","YYYYY");
if (!$con)
die ('could not connect: '.mysql_error());

mysql_select_db("XXXXXX", $con)
or die("cannot select DB");
// username and password sent from form
// To protect MySQL injection (more detail about MySQL injection)
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);

$sql="SELECT username,password FROM Customer_Infor WHERE username='$username' and

// Mysql_num_row is counting table row
// If result matched $email and $password, table row must be 1 row

// Register $myusername, $mypassword and redirect to file "login_success.php"
else {
echo "Wrong Username or Password";

That means your query failed. Try:

$result = mysql_query($sql) or die(mysql_error());

customer_infor is the table name where the username and password are stored

thank you pritaeas, it has worked.