Problem connecting a database

0

I was able to solve some of the problem. The error that I put below, in the initial part, was giving of my service of the mysql to be stopped. I do not know how, but somehow, after I started by WAMP, it stopped. After I started again, I did not give the initial error, but gave another, which I believe is simpler to solve, but I do not understand why it was given. Follow it:

  

Access denied for user 'root' @ 'localhost' (using password: YES)

I tested the user and password for this connection in the workbench and it gives an established connection. I do not understand why you give this error. Can someone help me? Thanks again.

NOTE: I left the initial report for you to understand the context, okay?

Good evening.

I'm trying to do a bank connection test in a simple file, but it's giving an error and I can not connect the bank. The error on the page is:

  

"Warning: mysqli :: mysqli (): Server sent charset (255) unknown to the client. Please, report to the developers in C: \ wamp64 \ www \ crud-bootstrap-php \ inc \ database.php on line 13 "

I'm using local server with the WAMP package. Even putting the localhost, it does not work. I tried several times, I created another user in the bank, nothing. Could anyone help? My main page looks like this:

<?php require_once 'config.php'; ?>
<?php require_once DBAPI; ?>

<?php

$db = open_database();

if($db){
    echo '<h1>Banco de Dados conectado!</h1>';
} else{
    echo '<h1>ERRO: Não foi possível conectar!</h1>';
}

?>

My connection file with the bank:

<?php
mysqli_report(MYSQLI_REPORT_STRICT);

function open_database(){
try{
    $conn = new mysqli(DB_HOST,DB_USER, DB_PASSWORD,DB_NAME);
    return $conn;
} catch (Exception $e){
    echo $e->getMessage();
    return null;
}
}

function close_database($conn){
try{
    mysqli_close($conn);
} catch (Exception $e){
    echo $e->getMessage();
}
}

?>

My config.php file:

<?php

/*o nome do banco de dados*/
define('DB_NAME', 'wda_crud');

/*Usuário do banco de dados MySQL*/
define('DB_USER','root');

/*Senha do banco de dados MySQL*/
define('DB_PASSWORD','');

/*nome do host do MySQL*/
define('DB_HOST','locahost');

/*caminho absoluto para a pasta do sistema*/
if(!defined('ABSPATH'))
    define('ABSPATH',dirname(__FILE__) . '/');

/*caminho no server para o sistema*/
if(!defined('BASEURL'))
    define('BASEURL','/crud-bootstrap-php/');

/*caminho do arquivo de banco de dados*/
if(!defined('DBAPI'))
    define('DBAPI',ABSPATH . 'inc/database.php');
?>
    
asked by anonymous 02.12.2018 / 03:46

0 answers