Availability of databases and tables given in the code: DATABASE - database, TABLES - users

<?php echo 'Проверка работоспособности проекта!'; $db = mysqli_connect( "127.0.0.1", "root", "root"); mysqli::select_db("database", $db); $result = mysqli::query("SELECT * FROM `users` "); var_dump($result); 

In the browser, the project shows a white screen (although the test echo itself works) ...

  • The code should not be invented by oneself, but taken from the examples in the documentation. - Ipatiev
  • I looked at the use of mysqli in the textbook pkhp - Alexander
  • one
    @ Alexander from the textbook also need not to fantasize, but to copy exactly. Programming is not literature, it’s not written in your own words. - Ipatiev
  • one
    @Alexander, look at the documentation , there are excellent examples with connection checks at every stage. Also perform a simple query to verify that the connection works without being bound to anything. select 1+1 - Alex Krass

1 answer 1

Try it like this.

 // полезные настройки PHP error_reporting(E_ALL); ini_set('display_errors',1); date_default_timezone_set('Europe/Moscow'); // задаем параметры подключения $db_hostname = 'localhost'; $db_database = 'database'; $db_username = 'root'; $db_password = 'root'; // устанавливаем режим выброса исключений при ошибках mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); // создаем соединение $connection = new mysqli($db_hostname, $db_username, $db_password, $db_database); mysqli_set_charset($connection, "utf8"); // выполняем запрос $result = $connection->query("SELECT * FROM users"); $myrow = $result->fetch_assoc(); echo $myrow['ИМЯ СТОЛБЦА']; 
  • Comments are not intended for extended discussion; conversation moved to chat . - Nick Volynkin