PHP Warning: mysqli_close () expects parameter 1 to be mysqli, boolean given

0

I'm having this problem. Does anyone know why? This is from a php book

Mylogcontainsthis

[Warning:mysqli_query()expectsparameter1tobemysqli,booleangivenin/var/www/html/php-oo/lv-77/mysql_lista.phponline7,referer: link

mysqli_close () expects parameter 1 to be mysqli, boolean given in / var / www / html / php-oo / lv-77 / mysql_lista.php on line 16, referer: link

    
asked by anonymous 01.10.2018 / 04:02

2 answers

0

Hello, I think that this is having problems with the connection to the database, check the user, password and if the bank and the table were properly created and also avoid giving spaces, try to do so:

$ conn = mysqli_connect ('127.0.0.1', 'root', 'mysql', 'book');

---- And also make sure you're putting the connection data in the correct position, here's an example below:

* db = Database

$ conn = mysqli_connect ('host_of_seu_db', 'db_user', 'db_password', 'db_name');

Test and see if it works, abqs.

    
01.10.2018 / 04:53
1

mysqli_connect () is probably failing, which assigns FALSE to the $ conn variable. I suggest putting a test after the connection, something like

if (mysqli_connect_errno()) {
  echo "Falhou ao conectar com MySQL: " . mysqli_connect_error();
}
    
01.10.2018 / 04:51