0

I just installed Ubuntu 20 and installed web server on it. Everything works well, but I cannot access database.

In PHP I'm getting this error:127.0.0.1:51670 [500]: POST /exo1.php - Uncaught PDOException: SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' in /var/www/html/tp1/exo1.php:2 Stack trace: #0 /var/www/html/tp1/exo1.php(2): PDO->__construct() #1 {main} thrown in /var/www/html/tp1/exo1.php on line 2

When I try to read the fichier on chrome , it works, but i have noting . here my code

<?php

try
    {
        $bdd = new PDO('mysql:host=localhost;dbname=Banque', 'root', '');
    }
    catch (Exception $e)
    {
    die('Erreur : ' . $e->getMessage());
    }


$requetes =$bdd ->query ('select *from client');
while ($donnees = $reponse->fetch())
    {   
         echo $donnees['nom'];
         echo $donnees['id'];
    }

?>

Dharman
  • 26,923
  • 21
  • 73
  • 125

0 Answers0