SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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 :
    Code:
    <?php
    $lien = mysqli_connect('localhost','root','');
    if(!$lien)
    {
    $resultat='impossible_de_se_connecter_au_serveur_Mysql';
    include 'resultat.html.php';
    exit();
    }
    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';
    exit();
    }
    if(!mysqli_select_db($lien, "ouvrage"))
    {
    $resultat = 'la base de donn&eacute;es des blagues  est introuvable';
    include 'resultat.html.php';.";//message = no success
    exit();
    }
    $resultat = 'connexion &agrave;la base r&eacute;ussie.';.";//message = no connected database
    include 'resultat.html.php';
    ?>
    and

    resultat.html.php :

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml1-strict.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <head>
    <title>resultat de PHP</title>
    <meta http-equiv="Content-Type" content="text/html: charset=utf-8" />
    </head>
    <body>
    <p>
    <?php echo $resultat ?>;
    </p>
    </body>
    </html>
    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,

    Philippe

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2012
    Location
    Scarborough, North Yorkshire, United Kingdom
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you got MySQL installed on your set-up?

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

    Try:

    PHP Code:
    $lien mysqli_connect('localhost','root','root'); 

  3. #3
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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),
    waiting,
    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

    Philippe



    Thank you

  4. #4
    SitePoint Zealot
    Join Date
    Jul 2012
    Location
    Scarborough, North Yorkshire, United Kingdom
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •