+1 vote
in Databases by (64.6k points)

I am getting the following error in my PHP code:

Got error 'PHP message: PHP Fatal error:  Uncaught ArgumentCountError: mysqli_connect_errno() expects exactly 0 arguments, 1 given

How to fix this error?

My code is:

if(mysqli_connect_errno($connection)){

echo "Could not connect to DB: <br />" . mysqli_connect_error();

}

1 Answer

+3 votes
by (86.3k points)
selected by
 
Best answer

The error in your code is caused by the argument in the mysqli_connect_errno() function. The function does not accept any arguments. However, in your code, you are passing "$connection" as an argument to it.

Remove the argument from the function and it will fix the error.

Here is the modified code:

if (mysqli_connect_errno()) {

    echo "Could not connect to DB: <br />" . mysqli_connect_error();

}

Related questions


...