Code PHP qui ne marche pas

Bonsoir à tous,
Au fait j'ai un gros problème avec mon code.
Je peine à afficher ma base de donnée pourtant il m'affiche pas d'erreur.
Si vous pouvez y jeter un coup d'oeil pour m'éclairer ce sera bien aimable de votre part.
Merci d'avance.
<?php
session_start();
?>

<html>
<head>
</head>
<body background="bg.jpg">
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">

<body>
<FONT COLOR="Pink" FACE="Ravie" >
<Strong>
<?php //Connection avec la BDD.
$liaison=mysql_connect("localhost", "root", "");
mysql_select_db("hitmusic");

$reponse = mysql_query("SELECT * FROM chanson");
?>

<h1>
<p align='center'> <STRONG> <FONT COLOR="Pink" SIZE="4" FACE="Ravie" >Toute la Musique </font> </STRONG></p> </h1>

<table>
<tr>
<th><p align='center'><FONT COLOR="Pink" SIZE="4" FACE="Ravie" > Titre </font></th> </p>
<th><FONT COLOR="Pink" SIZE="4" FACE="Ravie" > Date </font></th>
<th><FONT COLOR="Pink" SIZE="4" FACE="Ravie" > Style </font></th>
<th><FONT COLOR="Pink" SIZE="4" FACE="Ravie" > Fichier MP3 </font></th>
<th><FONT COLOR="Pink" SIZE="4" FACE="Ravie" > Artiste </font></th>
<th><FONT COLOR="Pink" SIZE="4" FACE="Ravie" > Image </font></th>
<th><FONT COLOR="Pink" SIZE="4" FACE="Ravie" > lien </font></th>
</tr>
<?php //On affiche les lignes du tableau une à une à l'aide d'une boucle
while($donnees = mysql_fetch_array($reponse)!==false)
{
?>
<tr>
<td><?php echo $donnees['Titre'];?></td>
<td><?php echo $donnees['Date'];?></td>
<td><?php echo $donnees['Style'];?></td>
<td><?php echo $donnees['FichierMP3'];?></td>
<td><?php echo $donnees['Artiste'];?></td>
<td><?php echo $donnees['Image'];?></td>
<td><?php echo $donnees['Wikipedia'];?></td>
</tr>
<?php T_ENDWHILE; ?>
</table>
</Font>
</STRONG>
</body>
</html>
<?php
} //fin de la boucle, le tableau contient toute la BDD
mysql_close( $liaison); //deconnection de mysql
?>

1 réponse

  1. Bonsoir,

    Deux problèmes..

    Il faut que tu remontes ton accolade de la fin de ta boucle, là tu auras une répétition des balises table, font, strong, body, html, bref :)

    Donc ton dernier bout de code PHP :
    <?php 
    } //fin de la boucle, le tableau contient toute la BDD 
    mysql_close( $liaison); //deconnection de mysql 
    ?>

    Tu le mets à la place de :
    <?php T_ENDWHILE; ?> 


    Pour ce qui est du deuxième soucis, supprime le FALSE de ton while, ce qui donne :
    while($donnees = mysql_fetch_array($reponse)) 


    Voilà ça marche !
    0
    1. Oui ça marche !! Merci Beaucoup
      0
    2. De rien !
      0