Getting a warning message mysqli_query expects parameter 1 to be mysqli, null given

前端 未结 2 757
庸人自扰
庸人自扰 2021-01-27 19:51

I keep getting this error from my code

Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\\xampp\\htdocs\\citizenssuites\\site\\pages\\re         


        
相关标签:
2条回答
  • 2021-01-27 20:25

    You didn't call mysqli_connect first, or it failed. Set $connection to a valid connection first:

    mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
    $connection = mysqli_connect("hostname", "username", "password");
    $result = mysqli_query($connection, ...);
    
    0 讨论(0)
  • 2021-01-27 20:27

    The function mysqli_connection fails (or did you forget calling it?) and returns null which causes the error when you try to use $connection later on with mysqli_query.

    0 讨论(0)
提交回复
热议问题