学校项目PHP的麻烦

时间:2018-01-02 19:50:00

标签: php sql

任何人都可以在这里帮助我吗?

我正在使用PHP脚本和数据库,每当我尝试登录时都会收到错误。

错误:

  

注意:未定义的变量:con in   第65行的C:xampp \ htdocs \ lp2 \ projeto \ login.php警告:   mysqli_num_rows()期望参数1为mysqli_result,给定null   在第68行的C:\ xampp \ htdocs \ lp2 \ projeto \ login.php

脚本

include('dbcon.php');
if (isset($_POST['login'])) {
    $user  = $_POST['uname'];
    $passw = $_POST['pass'];

    $qry  = "SELECT * FROM admin WHERE username='$user' AND password='$passw';";
    $run  = mysqli_query($con, $qry);
    $data = mysqli_fetch_assoc($run);

    $row = mysqli_num_rows($run); //count no. of rows of our query
    if ($row == 1) {
        $id              = $data['admin_id'];
        $_SESSION['uid'] = $id;
        header('location:admin/admindash.php');

dbcon

$servidor   = "localhost";
$utilizador = "root";
$pass       = "#Qwerty3";
$bd         = "library_management_system";

$ligacao = new mysqli($servidor, $utilizador, $pass, $bd);

if ($ligacao->connect_error) {
    die("Erro de conexao:" . $ligacao->connect_error);
}

1 个答案:

答案 0 :(得分:-3)

只需从select语句中删除多余的分号,它就会很好。