PHP Warning: mysqli_close() expects Parameter 1 to be mysqli, Boolean Given

Asked

Viewed 551 times

0

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

Codigo

My log reads this

[Sun Sep 30 22:56:16.203629 2018] [php7:warn] [pid 31940] [client :1:53268] PHP Warning: mysqli_query() expects Parameter 1 to be mysqli, Boolean Given in /var/www/html/php-oo/Lv-77/mysql_lista.php on line 7, referer: http://localhost/php-oo/Lv-77/

[Sun Sep 30 22:56:16.203662 2018] [php7:warn] [pid 31940] [client :1:53268] PHP Warning: 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: http://localhost/php-oo/Lv-77/

2 answers

1

Probably mysqli_connect() is 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();
}

0


Hello, i think this having problems with connection to the database, check the user, password and if the database and 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 check that you are putting the connection data in the correct position, follow an example below:

* db = Database

$Conn = mysqli_connect('host_do_seu_db','usuario_db','senha_db','name_db');

Test and see if it works, abçs.

  • That was it. Thank you VCS 2 for the great help

Browser other questions tagged

You are not signed in. Login or sign up in order to post.