警告:mysqli_num_rows()要求参数1为mysqli_result,第34行给出布尔值

时间:2017-05-31 18:12:16

标签: php

我在php上有这个警告信息:mysqli_num_rows()期望参数1是mysqli_result,布尔值在

中给出

我的代码是注册表格:

<?php
include('config.php');
session_start();

$username='';
$password='';
$password2='';
$fname='';
$sname='';
$dept='';
$faculty='';
$institution='';

$method = $_SERVER['REQUEST_METHOD'];
if($method == 'POST') 
{
    $username=trim($_POST['username']);
    $password=trim($_POST['password']);
    $password2=trim($_POST['password2']);
    $fname=trim($_POST['name']);
    $sname=trim($_POST['surname']);
    $dept=trim($_POST['department']);
    $faculty=trim($_POST['faculty']);
    $institution=trim($_POST['institution']);

    if($password!=$password2){
        echo 'Passwords do not mach. Please refresh';
    }


    $result1 = mysqli_query($db, "insert into student(sname, ssurname, sbrirthdate, sdepartment, sfaculty, sinstitution) values('" . $username . "', '" . $password . "', '" . $fname . "', '" . $sname . "', '" . $dept . "', '" . $faculty . "', '" . $institution . "')");
    $result2 = mysqli_query($db, "insert into admin(username, password) values('" . $username . "', '" . $password . "')");

    $count1 = mysqli_num_rows($result1);
    $count2 = mysqli_num_rows($result2);

    if($count1>0 && $count2>0){

        header ("location: http://localhost/xampp/baseis/mainpage.php");
    }
    else
    {
        die("error");
    }
}   

错误信息在线上: $ count1 = mysqli_num_rows($ result1);和$ count2 = mysqli_num_rows($ result2);

0 个答案:

没有答案