2014-10-27 127 views
-3

這是我的代碼如下。解析錯誤:語法錯誤,意外T_CONSTANT_ENCAPSED_STRING第109行mainPage.php

<h2 align=center><strong>Fan Pages</strong></h2> 
<?php 
error_reporting (E_ALL^E_NOTICE); 
$query = "SELECT pageName FROM pages"; 
//loop through the results and display them 
    while ($row = $results->fetch_assoc()) 
    { 
'<a href = "viewFanPage.php?id=<?php echo '.$row['page_ID']'; ?>"><?php echo '.$row['pageName']'; ?></a>'; 
    } 

>

我想要的名字字段以呼應的鏈接,但我不斷收到此錯誤:? 解析錯誤:語法錯誤,意想不到的T_CONSTANT_ENCAPSED_STRING在\ mainPage.php上線109

我已經嘗試了一切,但仍然沒有進展,將不勝感激任何幫助。

謝謝。

+0

在while循環,你沒有離開PHP的模式,但它看起來像你想? – Musa 2014-10-27 02:59:06

+2

''。$ row ['page_ID']';'< - 你沒有正確拼接 – 2014-10-27 03:00:10

回答

2

引用的字符串不會自動輸出並且不會解釋<?php … ?>僞標籤。它看起來像你的意思是關閉並重新打開<?php … ?>來代替:

<h2 align="center"><strong>Fan Pages</strong></h2> 

<?php 
error_reporting (E_ALL^E_NOTICE); 

$query = "SELECT pageName FROM pages"; 

// loop through the results and display them 
while ($row = $results->fetch_assoc()) { 
?> 
    <a href="viewFanPage.php?id=<?php echo $row['page_ID']; ?>"> 
     <?php echo $row['pageName']; ?> 
    </a> 
<?php 
} 
?> 
+0

感謝您的及時響應。它工作完美。 – 2014-10-27 03:41:49

相關問題