afternoon all! I am having some issue writing a log in script for a website! this is my first ever attempt so i am hoping it is something very straight forward!!!!

I am getting the following error message - Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /websites/123reg/LinuxPackage21/dr/ea/mt/dreamteamauction.com/public_html/checklogin.php on line 15
Wrong Username or Password

line 15 is the $count=mysql_num_rows($result); part. any suggestiong? will be much apprecaited! thanks

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
$host="cust-mysql-123-06"; 
$username=""; 
$password="dummy"; 
$db_name="dummy"; 
$tbl_name="test"; 
mysql_connect("$host", "$username", "$password");
mysql_select_db("$db_name");
$username=mysql_real_escape_string($_POST['username']);
$password=mysql_real_escape_string($_POST['password']);
$sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
  session_register("username");
  session_register("password");
  header("location:login_success.php");
} else {
  echo "Wrong Username or Password";
}?>

Your call to mysql_query() failed and returned FALSE. Use mysql_error() to get details as to why the query failed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.