警告:mysqli_query() 需要至少 2 个参数,其中 1 个在我的 php 文件中给出

Warning: mysqli_query() expects at least 2 parameters, 1 given in in my php file

我正在尝试在 php 代码中编写代码以更新 table 但是我在这里收到警告为什么我在这里收到此警告

这是我的代码

$con=mysqli_connect("localhost","root","root","clothing");
// Check connection
if (mysqli_connect_errno()){
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

if(isset($_POST['change'])){
    $email=$_POST['email'];
    $sql="SELECT *from userdetails WHERE userId='$userid'";

    $query = mysqli_query($con, $sql);
    $count=mysqli_num_rows($query);
    $row=mysqli_fetch_array($query);
    if ($count > 0){
        echo $row["Password"];
        echo  $_POST["currentPassword"];
        if($_POST["currentPassword"] == $row["Password"]) {
            echo "fine";
        if( $_POST["confirmPassword"]== $_POST["newPassword"]){
            mysqli_query("UPDATE userdetails SET Password='anil' WHERE ID=30");
            echo "good";
        }
    }
} 

我怎样才能得到我想要的输出

提前致谢

您没有向 mysqli_query - $con 提供这两个参数。使用下面的代码

  $con=mysqli_connect("localhost","root","root","clothing");
    // Check connection
    if (mysqli_connect_errno())
      {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }

        if(isset($_POST['change']))
        {
        $email=$_POST['email'];
            $sql="SELECT *from userdetails WHERE userId='$userid'";

        $query = mysqli_query($con, $sql);
                $count=mysqli_num_rows($con,$query);
                $row=mysqli_fetch_array($con,$query);
                if ($count > 0){
                echo $row["Password"];
                echo  $_POST["currentPassword"];
                if($_POST["currentPassword"] == $row["Password"]) {
                echo "fine";
                if( $_POST["confirmPassword"]== $_POST["newPassword"])
        {

        mysqli_query($con,"UPDATE userdetails SET Password='anil' WHERE ID=30");
        echo "good";
         }

       }

     }
     }

希望对您有所帮助

您没有在查询中包含 $con。

mysqli_query($con, "UPDATE userdetails SET Password='anil' WHERE ID=30");

如果不添加 $con,您的查询将失败。