我在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);