Php 我一直有未捕获的TypeError:mysqli_error():参数#1($mysql)必须是mysqli类型,bool-given

Php 我一直有未捕获的TypeError:mysqli_error():参数#1($mysql)必须是mysqli类型,bool-given,php,html,mysqli,Php,Html,Mysqli,如果有人能帮我解决问题,我将不胜感激。 其中一个问题是,当我输入正确的数据并按submit时,它会不断显示此错误: Fatal error: Uncaught TypeError: mysqli_error(): Argument #1 ($mysql) must be of type mysqli, bool given in /opt/lampp/htdocs/Try_Project/ServerForm.php:70 Stack trace: #0 /opt/lampp/htdocs/Tr

如果有人能帮我解决问题,我将不胜感激。 其中一个问题是,当我输入正确的数据并按submit时,它会不断显示此错误:

Fatal error: Uncaught TypeError: mysqli_error(): Argument #1 ($mysql) must be of type mysqli, bool given in /opt/lampp/htdocs/Try_Project/ServerForm.php:70 Stack trace: #0 /opt/lampp/htdocs/Try_Project/ServerForm.php(70): mysqli_error(false) #1 /opt/lampp/htdocs/Try_Project/SignUp.php(16): include('/opt/lampp/htdo...') #2 {main} thrown in /opt/lampp/htdocs/Try_Project/ServerForm.php on line 70
另一个是,我不能显示所有的错误,重复的电子邮件,重复的电话号码和两个密码不匹配

这是主要注册代码:

<?php 
ini_set('display_errors', 1);  
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>
<?php
 $duplicateEmail="";
 $duplicatePhone="";
 $notEqual="";
 $insertSuccess=false;
 $emailExist=false;
 $phoneExist=false;
 $passwordER=false;
 ?>

<?php include('ServerForm.php') ?>
<!DOCTYPE html>
<html>
<head>
    <title>The Silk Flower</title>
    <meta charset="utf8">
    <link rel="stylesheet" type="text/css" href="styles1.css">
</head>
<body>
    <?php include('includes/header.php') ?>

     
    <br>
    <br>
    <center><div>
        
        <?php 
    if($insertSuccess){
    header('location: index.html');
    }
        ?>
         <!-- start of the sign up page --> 
        <h1 class="title">Sign up</h1>
    </div>

        <!-- sign up form --> 
    <form method="post" action="<?php $_SERVER['PHP_SELF']?>" name="login" >

  <div class="container">
    <label for="Fname"><b>First Name</b></label>
    <input type="text" placeholder="First Name" name="Fname" autofocus required>
    
    <label for="Lname"><b>Last Name</b></label>
    <input type="text" placeholder="Last Name" name="Lname" required>
    
    <label for="email"><b>Email</b></label>
    <input type="email" placeholder="Enter Email" name="email" required>

    <label for="psw"><b>Password</b></label>
    <input type="password" placeholder="Enter Password" name="psw" minlength="8"  required>
    
    <label for="psww"><b>Confirm Password</b></label>
    <input type="password" placeholder="Re-enter Password" name="psww" minlength="8"  required>
    
    <label for="t"><b>Phone</b></label>
    <input type ="tel" placeholder="eg. 0500000000" name = "t" required pattern="[0]{1}[5]{1}[0-9]{8}" maxlength="10">
    
    <label for="add"><b>Address</b></label>
    <input type="text" placeholder="Address" name="add" maxlength="60" required>
    
        <div class="product">
            <button style="width: auto" type="submit" name = "submit">Sign up</button>
      </div>
      <?php
        if($emailExist){
        print("<br><p style='color:red; margin-left:10px;'>". $duplicateEmail." </p>");}
         if ($phoneExist){
               print("<br><p style='color:red; margin-left:10px;'>". $duplicatePhone." </p>");}
         if ($passwordER){
               print("<br><p style='color:red; margin-left:10px;'>". $notEqual." </p>");}
        ?> 

  </div>
</form>
</center>
 <p> 
    
          <strong> <a href = "#top"> <img src="images/arrowtop.png" width="40" height="40">
              </a></strong>
         </p>
</body>
</html>

绢花


注册 您向提供了一个结果,而您应该提供一个数据库句柄。因此,请替换:

$result2 = mysqli_query($db,$checkexistemail);
$result3 = mysqli_query($db,$checkexistphone);

if (!($result2) || !($result3))
     {
     print ("<p> Query couldn't be executed </p>");
     echo mysqli_error($result2);
     echo mysqli_error($result3);
     }
$result2=mysqli\u查询($db,$checkexistemail);
$result3=mysqli\u查询($db,$checkexistphone);
如果(!($result2)| |!($result3))
{
打印(“查询无法执行”

”; echo mysqli_错误($result2); echo mysqli_错误($result3); }
作者:

$result2=mysqli\u查询($db,$checkexistemail);
如果(!$result2){
echo“无法执行查询[$checkexistemail]

”; echo mysqli_错误($db); } $result3=mysqli\u查询($db,$checkexistphone); 如果(!$result3){ echo“无法执行查询[$checkexistphone]

”; echo mysqli_错误($db); }
我的错误很简单,我忘了在$add附近的末尾添加一个引号。。。非常尴尬


我还修复了每个mysqli_错误

感谢您的回复,您有没有解决插入问题的方法?
$result2 = mysqli_query($db,$checkexistemail);
$result3 = mysqli_query($db,$checkexistphone);

if (!($result2) || !($result3))
     {
     print ("<p> Query couldn't be executed </p>");
     echo mysqli_error($result2);
     echo mysqli_error($result3);
     }
$result2 = mysqli_query($db,$checkexistemail);
if (!$result2) {
    echo "<p> Query [$checkexistemail] couldn't be executed </p>";
    echo mysqli_error($db);
}
$result3 = mysqli_query($db,$checkexistphone);
if (!$result3) {
    echo "<p> Query [$checkexistphone] couldn't be executed </p>";
    echo mysqli_error($db);
}