Warning: mysqli_error() expects exactly 1 parameter, 0 given error

后端 未结 4 1577
夕颜
夕颜 2020-11-27 19:58

I get the following error

Warning: mysqli_error() expects exactly 1 parameter, 0 given

The problem is with this line of the c

相关标签:
4条回答
  • 2020-11-27 20:05

    mysqli_error function requires $myConnection as parameters, that's why you get the warning

    0 讨论(0)
  • 2020-11-27 20:21

    Change

    die (mysqli_error()); 
    

    to

    die('Error: ' . mysqli_error($myConnection));
    

    in the query

    $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error()); 
    
    0 讨论(0)
  • 2020-11-27 20:21

    At first, the problem is because you did't put any parameter for mysqli_error. I can see that it has been solved based on the post here. Most probably, the next problem is cause by wrong file path for the included file.. .

    Are you sure this code

    $myConnection = mysqli_connect("$db_host","$db_username","$db_pass","$db_name") or die ("could not connect to mysql");
    

    is in the 'scripts' folder and your main code file is on the same level as the script folder?

    0 讨论(0)
  • 2020-11-27 20:27

    mysqli_error() needs you to pass the connection to the database as a parameter. Documentation here has some helpful examples:

    http://php.net/manual/en/mysqli.error.php

    Try altering your problem line like so and you should be in good shape:

    $query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error($myConnection)); 
    
    0 讨论(0)
提交回复
热议问题