I cannot connect a database created with phpmysql

Reading PHP & MYSQL from Kevin Yank, 4th edition;

I put those two files in the directory “connexion” under www as said in the book :

index.php :

$lien = mysqli_connect('localhost','root','');
include 'resultat.html.php';
if(!mysqli_set_charset($lien, 'utf8'))
$resultat = "impossible de cofigurer l'encdage de la connexion &agrave;la base.";//message = no success
include 'resultat.html.php';
if(!mysqli_select_db($lien, "ouvrage"))
$resultat = 'la base de donn&eacute;es des blagues  est introuvable';
include 'resultat.html.php';.";//message = no success
$resultat = 'connexion &agrave;la base r&eacute;ussie.';.";//message = no connected database
include 'resultat.html.php';


resultat.html.php :


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<title>resultat de PHP</title>
<meta http-equiv="Content-Type" content="text/html: charset=utf-8" />
<?php echo $resultat ?>;

and I get the last error message : no connected database
that exemple is in the 4 th chapter of the 4 th edition de PHP & MYSQL about Kevin Yank

Would you give me a reason why ?

Thank you very much,


Have you got MySQL installed on your set-up?

You aren’t passing a password, is this correct?


$lien = mysqli_connect('localhost','root','root');

Y have all install with wampserver and Y have leave my password as “”.
I will try what you say but, I am at work (Y have not a computering job Y just may sending mail), all what Y try for my learning PHP and MySql is at home so I will wait that evening, (at home),
thanks so much for your help and I shall naturally keep you informed of any result about your suggestion when I recover my computer at ome that evening.

P.S. : Y try the same with “Java and OBCD” and Y do a query with success, with the same database, the same wampserver, and Y think that my PHP code is Ok, so Y think it’s strange


Thank you

Hi Philipe, quick note on your English, you need to be writing ‘I’ not ‘Y’:

I have all install with wampserver and I have leave my password as” :slight_smile: