Проблемы с логином .php
Я создаю форму входа в систему, но всегда получаю предупреждение об ошибке.
Предупреждение: mysqli_fetch_array() ожидает, что параметр 1 будет mysqli_result, логическое значение задано в C:\xampp\htdocs\login\login.php на линии 13
Предупреждение: mysqli_num_rows() ожидает, что параметр 1 будет mysqli_result, логическое значение задано в C:\xampp\htdocs\login\login.php на линии 16
Что я уже пробовал:
<?php include("config.php"); session_start(); if($_SERVER["REQUEST_METHOD"] == "POST") { // username and password sent from form $myusername = mysqli_real_escape_string($db,$_POST['username']); $mypassword = mysqli_real_escape_string($db,$_POST['password']); $sql = "SELECT id FROM username WHERE id = '$myusername' and passcode = '$mypassword'"; $result = mysqli_query($db,$sql); $row = mysqli_fetch_array($result,MYSQLI_ASSOC); $active = $row['active']; $count = mysqli_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count == 1) { session_register("myusername"); $_SESSION['login_user'] = $myusername; header("location: table.php"); }else { $error = "Your Login Name or Password is invalid"; } } ?> <html> <head> <title>Recorder Penguin</title> <script defer src="https://use.fontawesome.com/releases/v5.0.9/js/all.js" integrity="sha384-8iPTk2s/jMVj81dnzb/iFR2sdA7u06vHJyyLlAd4snFpCl/SnyUjRrbdJsw1pGIl" crossorigin="anonymous"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" /> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <style> html { background: url(icy_cold_blue_by_ivanthelonewolf-d3kq23z.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } body{ background: none; } .jumbotron{ background-color:rgba(0, 204, 204,0.3); } </style> <nav class="navbar navbar-light bg-faded"> <div class="container"> <div class="navbar-header"> <a class="nav navbar-nav" > <li><img src="LOGO4.png" width="60" height="60" class="d-inline-block align-top" alt=""></li> <li><h2 class="nav-brand-nav">RECORD PENGUIN</h2></li> </div> <ul class="nav navbar-right navbar-right" style="margin-top:30px "> <li><ul><a href="register.php"> Register</a></li><ul> </ul> </div> </nav> <div class="container"> <div class="jumbotron"> <form action = "" method = "post"> <label>UserName :</label><input type = "text" name = "username" class = "box"/><br /><br /> <label>Password :</label><input type = "password" name = "password" class = "box" /><br/><br /> <button type = "submit" class="btn btn-success btn-lg"id="submit"name="submit" value = " Submit "/>Login</button><br /> </form> <div style = "font-size:14px; color:#cc0000; margin-top:10px"><?php echo $error; ?></div> </div> </div> </div> </body> </html>