预期参数错误php

时间:2018-05-01 23:11:38

标签: php mysql

我在托管服务器上传时出现此错误,但在localhost中,网站状况良好,php版本设置为7.1。

  

警告:mysqli_query()需要至少2个参数,第42行/storage/ssd3/410/5444410/public_html/update.php中给出的参数为1

     

警告:mysqli_fetch_array()要求参数1为mysqli_result,在第43行的/storage/ssd3/410/5444410/public_html/update.php中给出null

代码:

<?php 
    $conn_db = mysqli_connect("localhost","user","password") or die();
    $sel_db = mysqli_select_db($conn_db, "dbname") or die();
    if(isset($_POST['update_password']))
    {
    $old_password=$_POST['old_password'];
    $new_password=$_POST['new_password'];
    $confirm_password=$_POST['confirm_password'];
    $chg_pwd=mysqli_query("SELECT * from member WHERE username='$user_check'"); //line 42
    $chg_pwd1=mysqli_fetch_array($chg_pwd); //line 43
    $data_pwd=$chg_pwd1['password'];
    if($data_pwd==$old_password){
    if($new_password==$confirm_password){
        $update_password=mysqli_query("UPDATE member SET password='$new_password' WHERE username='$user_check'");
        $viewpass = 'UPDATED SUCCESSFULLY!';
    }
    else{
        $errMsg = 'PASSWORD DOES NOT MATCH!';
    }
    }
    else
    {
    $errMsg2 = 'OLD PASSWORD IS WRONG!';
    }}
?>

我只是制作了一个简单的照片组合网站,我不知道如何处理这个问题。

1 个答案:

答案 0 :(得分:0)

试试这个

$chg_pwd=mysqli_query($conn_db,"SELECT * from member WHERE username='$user_check'"); 
$chg_pwd1=mysqli_fetch_array($chg_pwd, MYSQLI_ASSOC); 

用于关联数组,或

$chg_pwd1=mysqli_fetch_array($chg_pwd, MYSQLI_NUM); 

表示数字数组。