Noob en php et marche pas mon scripte

Résolu
Bonjour, j'ai un problème voila le code

<?php include "14428/config.php";?>
<?php
$req = mysql_query('SELECT pseudo, message, date, tipe FROM minichat ORDER BY ID DESC LIMIT 0, 6');
while($dnn = mysql_fetch_array($req))
{
?>
<p><strong><?php echo htmlentities($dnn['pseudo'], ENT_QUOTES, 'UTF-8'); ?></strong> :
<?php if ($_SESSION['tipe'] ==0) echo htmlentities($dnn['message'];
if ($dnn['tipe'] ==1) echo '<img src="'.htmlentities($dnn['message'].'" border="0">';
if ($dnn['tipe'] ==2) echo '<a href="'.htmlentities($dnn['message'].'">'.htmlentities($dnn['message'].'</a>';
if ($dnn['tipe'] ==3) echo 'administrateur';
?>

<font size="1">a <?php echo htmlentities($dnn['date'], ENT_QUOTES, 'UTF-8'); ?></font></p>
<?php
}
?>

et il me dit sa

Parse error: parse error in C:\wamp\www\lol\chat.php on line 8

5 réponses

  1. <?php include "14428/config.php";?>
    <?php
    $req = mysql_query('SELECT pseudo, message, date, tipe, tipe2 FROM minichat ORDER BY ID DESC LIMIT 0, 6');
    while($dnn = mysql_fetch_array($req))
    {
    $type = array(0=>'<img src="',1=>'<font size="2"><a href="');
    $type2 = array(0=>'" border="0">',1=>'">il a afichier un lien </a></font>');
    ?>
    <p><strong><font size="3"><?php echo htmlentities($dnn['pseudo'], ENT_QUOTES, 'UTF-8'); ?></strong> :</font>
    <?php echo $type[$dnn['tipe']]; ?><?php echo htmlentities($dnn['message'], ENT_QUOTES, 'UTF-8'); ?><?php echo $type2[$dnn['tipe2']]; ?>
    <font size="1">a <?php echo htmlentities($dnn['date'], ENT_QUOTES, 'UTF-8'); ?></font></p>
    <?php
    }
    ?>

    sa marche mieux ^^
    1. dans l'ancien sais sa qui et marche pas bien

      <?php if ($_SESSION['tipe'] ==0) echo htmlentities($dnn['message'];
      if ($dnn['tipe'] ==1) echo '<img src="'.htmlentities($dnn['message'].'" border="0">';
      if ($dnn['tipe'] ==2) echo '<a href="'.htmlentities($dnn['message'].'">'.htmlentities($dnn['message'].'</a>';
      if ($dnn['tipe'] ==3) echo 'administrateur';
      ?>
      1. a oui en faite tipe sa ve dire type enfaite quand tu écrie un message tu peu changer type 0 = message , type 1 image, type 2 lien et âpre ,type 3 vidéo mais j'ai pas encore mie
        1. merci a toi ! mais avec se lui la sa me fait sa Parse error: parse error in C:\wamp\www\lol\chat.php on line 13
          1. <?php
            	include "14428/config.php";
            	
            	$req = mysql_query('SELECT pseudo, message, date, tipe FROM minichat ORDER BY ID DESC LIMIT 0, 6');
            	
            	while($dnn = mysql_fetch_array($req)){
            		echo	"<p><strong>",
            				htmlentities($dnn['pseudo'], ENT_QUOTES, 'UTF-8'),
            				"</strong> :";
            		
            		// Selon le contenu de la variable 'tipe' faire :
            		switch($_SESSION['tipe']){
            			case 0: echo htmlentities($dnn['message'];
            					break;			
            			case 1: echo "<img src='".htmlentities($dnn['message']."' border='0'/>";
            					break;			
            			case 2: echo "<a href='".htmlentities($dnn['message']."'>htmlentities($dnn['message']</a>";
            					break;
            			case 3: echo "administrateur";
            					break;
            			default:
            					break;
            		}	
            
            		echo	"<font size='1'>a",
            				htmlentities($dnn['date'], ENT_QUOTES, 'UTF-8'),
            				"</font></p>";
            	}
            ?>


            Cela fonctionne mieux comme ça ? J'ai simplifié légèrement le code. Les erreurs de type "parse" viennent souvent de la mauvaise écriture des ' " ; ...
            Utilise un éditeur avec la coloration syntaxique du code pour t'aider (Linux : geany / gedit , Windows : notepad++).

            Cordialement.