2011-03-21 5 views
0

je reçois ce message d'erreur:

"Parse error: syntax error, unexpected $end in C:\Users\Stacky\Desktop\xampp\htdocs\wweff\stackhelp.php on line 822"

J'ai essayé d'obtenir ce code de travail en bricolant une seule ligne de mon code, ligne 54.

Voici le code complet. Attention à "// ^^^^ DROIT AU-DESSUS DE LA LIGNE 54". dans le code ci-dessous:

<html> 
<head> 
</head> 
<body> 
    <?php 
     $objConnect = mysql_connect("localhost","root","") or die(mysql_error()); 
     $objDB = mysql_select_db("thegoodhumor"); 
     $strSQL = "SELECT * FROM gallery"; 
     if (!isset($_GET['Page'])) $_GET['Page']='0'; 
     $objQuery = mysql_query($strSQL); 
     $Num_Rows = mysql_num_rows($objQuery); 
     $Per_Page = 16; // Per Page 

     $Page = $_GET["Page"]; 
     if(!$_GET["Page"]) 
     { 
      $Page=1; 
     } 

     $Prev_Page = $Page-1; 
     $Next_Page = $Page+1; 

     $Page_Start = (($Per_Page*$Page)-$Per_Page); 
     if($Num_Rows<=$Per_Page) 
     { 
      $Num_Pages =1; 
     } 
     else if(($Num_Rows % $Per_Page)==0) 
     { 
      $Num_Pages =($Num_Rows/$Per_Page) ; 
     } 
     else 
     { 
      $Num_Pages =($Num_Rows/$Per_Page)+1; 
      $Num_Pages = (int)$Num_Pages; 
     } 

     $strSQL .=" order by GalleryID ASC LIMIT $Page_Start , $Per_Page"; 
     $objQuery = mysql_query($strSQL); 
       $cell = 0; 
       echo '<table border="1" cellpadding="2" cellspacing="1"><tr>'; 
       while($objResult = mysql_fetch_array($objQuery)) 
       { 
        if($cell % 4 == 0) { 
        echo '</tr><tr>'; 
       } 

       if($cell == 2 || $cell == 3) { 
       echo '<td>RESERVED</td>'; 
       } else { 
       echo '<td><img src="https://s3.amazonaws.com/imagetitle/' . 
       $objResult["Picture"];?>" height="190" width="190" /> . .$objResult["GalleryName"].'\</td>'; 
       //^^^^ RIGHT ABOVE IS LINE 54. 
       } 
       $cell++; 
       } 
       echo '</tr></table>'; 
    ?> 
     <?php 
      //DELETED PAGINATION CODE for the sake of simplicity in StackOverflow 
     ?> 
     </body> 
     </html> 
     <?php 
     mysql_close($objConnect); 
     ?> 

Répondre

4
 $objResult["Picture"];?>" height="190" width="190" /> . .$objResult["GalleryName"].'\</td>'; 

Contient ?>, qui indique à l'interpréteur PHP d'arrêter l'interprétation, dans d'autres mots tout qui suit est le HTML brut.

Essayez de changer le ;?> à un ., mettre un ` avant height="190", et retirez le \ avant </td>, ce qui donne:

 $objResult["Picture"] . 'height="190" width="190" />' . 
      $objResult["GalleryName"] . '</td>'; 
+0

La solution parfaite à votre code @thomas. +1 à Mikel –

+0

Merde, très bien! Je vous remercie! –

0

Dans la partie suivante de code:

while($objResult = mysql_fetch_array($objQuery)) 
{ 
    if($cell % 4 == 0) { // A { is opened here 
    echo '</tr><tr>'; 
    // Maybe it should be closed here ? 
} 

Il semble que vous ne fermons pas la { qui correspond à la if.


Et, un peu plus bas dans votre code, vous avez un } qui ne semble pas appartenir là:

if($cell == 2 || $cell == 3) { 
    echo '<td>RESERVED</td>'; 
} else { 
    echo '<td><img src="https://s3.amazonaws.com/imagetitle/' . 
    $objResult["Picture"];?>" height="190" width="190" /> . .$objResult["GalleryName"].'\</td>'; 
    //^^^^ RIGHT ABOVE IS LINE 54. 
} // closing the else 
$cell++; 
} // what is this doing here ? 


Conseils généraux dans ce genre de situation: tiret votre code correctement !

Cela vous permettra d'attraper ce genre de problèmes beaucoup plus facilement ;-)
Et rendra votre code plus facile à lire, bien sûr.

+0

Un bon conseil hah, il a fonctionné dès le début. Merci pour la réponse bien-out! –

+0

De rien :-) Amusez-vous! –

1

Vous avez "?>" Au milieu de la ligne 54, qui indique PHP arrêter le pré-traitement (au milieu de votre déclaration d'écho). Vous voulez probablement supprimer cela.

+0

Ouais, euh, ça marche, merci;) –

Questions connexes