Ostrzeżenie: mysql_num_rows () oczekuje, że parametr 1 będzie zasobem, boolean podany w /home/folder/public_html/folder/folder/login.php w linii 18 [duplikat]

To pytanie ma już tutaj odpowiedź:

Ostrzeżenie: mysql_fetch_ * oczekuje, że parametr 1 będzie zasobem, boolean poda błąd [duplikat]

Próbuję skonfigurować moją bazę danych, ale niestety natknąłem się na pewne problemy. Widziałem, że wiele osób zadawało to samo lub podobne pytanie, ale bez względu na to, jak patrzę na mój kod i modyfikuję go. Coraz bardziej się mylę i dodaję więcej błędów. Więc jeśli ktoś mógłby mi wyjaśnić, w jaki sposób mogę to naprawić, będę wdzięczny.

Oto komunikat o błędzie:

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/folder/public_html/folder/folder/login.php on line 18

Oto kod:

<link rel="Stylesheet" type="text/css" href="style.css" />
<link href='http://fonts.googleapis.com/css?family=Karla:400,700,700italic,400italic' rel='stylesheet' type='text/css'>
<?php
$filename = 'install.php';
if (file_exists($filename)) {
echo ("<center><font color='red'><b>/install.php still exists<br>
After installing please delete install.php</center></font></b>");
} else {
if (isset($_POST['Login'])){
include('config.php');
    if (!mysql_connect($host, $username, $password)) die("Can't connect to database");
    if (!mysql_select_db($db_name)) die("Can't select database");
    $myusername=$_POST['myusername'];
    $mypassword=$_POST['mypassword'];

    $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
    $result=mysql_query($sql);
    $count=mysql_num_rows($result);
    if($count >= 1){
    session_register("myusername");
    session_register("mypassword");
    header("location: index.php");
    } else {
        echo "<center><font color='red'><b>Wrong Username or Password</center></font></b>";
    }
}
?>
<br>
<form method="post" action=""><td>
<table width="325" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#212121">
<td><table width="100%" border="0" cellpadding="3" cellspacing="0" bgcolor="#404040"></td>
<tr colspan="3"><strong><center> <font color="ECECEC"> Admin Login </font></center></strong></tr>
<tr>
<td>
<font color="ECECEC">Username </font><input name="myusername" type="text" id="myusername">
<font color="ECECEC">Password </font><input name="mypassword" type="password" id="mypassword">
</td>
<center><td><input type="submit" name="Login" value="Login"></td></center>
</table></table>
</form>
<?php
}
?>

Oto linia 18

        $count=mysql_num_rows($result);

questionAnswers(3)

yourAnswerToTheQuestion