2011-03-21 33 views
0

我收到此错误信息:

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

我一直试图让这个代码通过摆弄工作只有一行我的代码,第54行。

以下是完整的代码。注意“// ^^^^右上方是第54行”。在下面的代码:

<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); 
     ?> 

回答

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

包含?>,它告诉PHP解释器停止解释,换句话说,下面是原始HTML一切。

尝试改变;?>.,把一个前`height="190",并删除\</td>,赠送:

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

代码@thomas的完美解决方案。 +1到Mikel – 2011-03-21 05:43:56

+0

该死的,非常好!谢谢! – 2011-03-21 05:52:55

0

在下面的代码部分:

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

看来你不关闭对应于if{。在这种情况下

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 ? 


一般的建议:


在你的代码 而且,低一点,你有一个}似乎并不属于那里缩进你的代码正确!

这将允许你捕捉这种问题更容易;-)
而且会让你的代码更易于阅读,当然。

+0

很好的建议哈,从第一个工作。感谢您的良好反应! – 2011-03-21 05:55:36

+0

不客气:-)玩得开心! – 2011-03-21 05:56:40

1

你有 “?>”,在第54行的中间,它告诉PHP停止预处理(在echo语句的中间)。你可能想要删除它。

+0

是的,哈,得到它的工作,谢谢;) – 2011-03-21 05:54:06

相关问题