O
O
Oleg2020-04-30 19:10:04
PHP
Oleg, 2020-04-30 19:10:04

Can't connect to php database?

I can't help you figure out why. Error: Undefined variable: mysqli_connect_errno

<?php
  $mysqli = new mysqli('localhost','root','','test');
  if ($mysqli_connect_errno()){
    echo ("подключение невозможно!".mysqli_connect_error());
  }
  else{
    echo ("Вы успешно подключились");
  }
  $mysqli->close();
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2020-04-30
@0legdevlop

And now the correct answer .
At the very least, you should write like this:

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli('localhost','root','','test');
$mysqli->set_charset('utf8mb4');

And it is better completely as it is described under the link above.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question