H
H
HeartOfProgrammer2015-08-27 13:10:38
PHP
HeartOfProgrammer, 2015-08-27 13:10:38

Cause of error when connecting MySQL database?

I tried different types of connected Mysql databases, but still the interpreter swears forever on this line

$connection = mysqli_connect('localhost', 'project_user', '', 'project_db');

Although everything is correct in the code, local host, login, password, database.
here is the complete connection
function Mysqli_Query_index() {
    $connection = mysqli_connect('localhost', 'project_user', '', 'project_db');
    if(!$connection){
      printf("Ошибка подключения: %s\n", mysqli_connect_error());
      exit();
    }
    else {
      printf("Информация хоста: %s\n", mysqli_get_host_info($connection));
    }

    printf( $connection );

    $result = mysqli_query("SELECT * FROM news");

    while($row = mysqli_fetch_assoc($result)): ?>
    <div class="news-block">
      <a href="news.php?id=<?=$row_index['id']?>"><?=$row_index['title']?></a></h1>
      <a href="#">№<?=$row_index['id']?></a>
      <p class="content"><?=$row_index['main_content']?></p>
      <span>Автор: <b><?=$row_index['added']?>,</b></span>
      <span>Дата: <b><?=$row_index['add_date']?>,</b></span>
      <a href="#" class="read_more">Подробнее...</a>
      <hr>
    </div> <? endwhile;
  }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Сергей Зеленский, 2015-08-27
@SergeyZelensky-Rostov

это не ошибка, а предупреждение проверяйте пароль и логин и наличия прав у пользователя для работы с конкретной базой данных в вашем случае project_db

Макс, 2015-08-27
@MaxDukov

попробуйте
если конечно у вас пользователь без пароля

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question