2011-03-21 81 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

相關問題