2013-11-25 16 views
-2

所以,我在我的網站上添加了一個論壇部分。到目前爲止,每個人都很好。您可以創建一個主題,瀏覽主題列表,但是當你去查看一個主題(這是view_topic.php?id=#)這個不斷出現:包括

Parse error: syntax error, unexpected $end in /home/papervip/public_html/forums/questions/view_topic.php on line 158 

所以,這裏的view_topic.php的完整劇本(不含數據庫憑據,所以我可以保證我的安全:d):

<?php 
session_start(); 

$host="localhost"; // Host name 
$username=""; // Mysql username 
$password=""; // Mysql password 
$db_name=""; // Database name 
$tbl_name="forum_questions"; // Table name 

// Connect to server and select databse. 
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB"); 

// get value of id that sent from address bar 
$id=$_GET['id']; 
$sql="SELECT * FROM $tbl_name WHERE id='$id'"; 
$result=mysql_query($sql); 
$rows=mysql_fetch_array($result); 
?> 
<!DOCTYPE html> 
<html> 
<head> 
    <link rel="stylesheet" type="text/css" href="../../style/base.css"> 
    <title>Paperviper - Questions - View Topic</title> 
    <meta name="keywords" content="games, free, indie, paperviper, pc, video games"> 
    <meta name="description" content="Paperviper is a game developer group consisten of a team of indie-developers and freelancers. Working to bring you the best cheap and free games for addicting fun on your PC, Mac, and Linux!"> 
<style type="text/css"> 

</head> 
<body> 
<?php if(empty($_SESSION['user'])){ 
    include("../../header.html"); 
}else{ 
    include("../../user/user_header.html"); 
?> 
<div id="page"> 


<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> 
<tr> 
<td><table width="100%" border="0" cellpadding="3" cellspacing="1" bordercolor="1" bgcolor="#FFFFFF"> 
<tr> 
<td bgcolor="#F8F7F1"><strong><? echo $rows['topic']; ?></strong></td> 
</tr> 

<tr> 
<td bgcolor="#F8F7F1"><? echo $rows['detail']; ?></td> 
</tr> 

<tr> 
<td bgcolor="#F8F7F1"><strong>By :</strong> <? echo $rows['name']; ?> <strong>Email : </strong><? echo $rows['email'];?></td> 
</tr> 

<tr> 
    <td bgcolor="#F8F7F1"><strong>Date/time : </strong><? echo $rows['datetime']; ?></td> 
</tr> 
</table></td> 
</tr> 
</table> 
    <BR> 

<?php 

$tbl_name2="forum_questions_answer"; 
$sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'"; 
$result2=mysql_query($sql2); 
while($rows=mysql_fetch_array($result2)){ 
?> 

<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> 
<tr> 
    <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> 
<tr> 
    <td bgcolor="#F8F7F1"><strong>ID</strong></td> 
    <td bgcolor="#F8F7F1">:</td> 
    <td bgcolor="#F8F7F1"><? echo $rows['a_id']; ?></td> 
</tr> 
<tr> 
<td width="18%" bgcolor="#F8F7F1"><strong>Name</strong></td> 
<td width="5%" bgcolor="#F8F7F1">:</td> 
<td width="77%" bgcolor="#F8F7F1"><? echo $rows['a_name']; ?></td> 
</tr> 
<tr> 
<td bgcolor="#F8F7F1"><strong>Email</strong></td> 
<td bgcolor="#F8F7F1">:</td> 
<td bgcolor="#F8F7F1"><? echo $rows['a_email']; ?></td> 
</tr> 
<tr> 
<td bgcolor="#F8F7F1"><strong>Reply</strong></td> 
<td bgcolor="#F8F7F1">:</td> 
<td bgcolor="#F8F7F1"><? echo $rows['a_answer']; ?></td> 
</tr> 
<tr> 
<td bgcolor="#F8F7F1"><strong>Date/Time</strong></td> 
<td bgcolor="#F8F7F1">:</td> 
<td bgcolor="#F8F7F1"><? echo $rows['a_datetime']; ?></td> 
</tr> 
</table></td> 
</tr> 
</table><br> 

<?php 
} 

$sql3="SELECT view FROM $tbl_name WHERE id='$id'"; 
$result3=mysql_query($sql3); 
$rows=mysql_fetch_array($result3); 
$view=$rows['view']; 

/
if(empty($view)){ 
$view=1; 
$sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id='$id'"; 
$result4=mysql_query($sql4); 
} 


$addview=$view+1; 
$sql5="update $tbl_name set view='$addview' WHERE id='$id'"; 
$result5=mysql_query($sql5); 
mysql_close(); 
?> 

<BR> 
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> 
<tr> 
<form name="form1" method="post" action="add_answer.php"> 
<td> 
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> 
<tr> 
<td width="18%"><strong>Name</strong></td> 
<td width="3%">:</td> 
<td width="79%"><input name="a_name" type="text" id="a_name" size="45" value="<?php echo htmlentities($_SESSION['user']['username'], ENT_QUOTES, 'UTF-8'); ?>" readonly></td> 
</tr> 
<tr> 
<td><strong>Email</strong></td> 
<td>:</td> 
<td><input name="a_email" type="text" id="a_email" size="45" value="<?php echo htmlentities($_SESSION['user']['email'], ENT_QUOTES, 'UTF-8'); ?>" readonly></td> 
</tr> 
<tr> 
<td valign="top"><strong>Reply</strong></td> 
<td valign="top">:</td> 
<td><textarea name="a_answer" cols="38" rows="10" id="a_answer"></textarea></td> 
</tr> 
<tr> 
<td>&nbsp;</td> 
<td><input name="id" type="hidden" value="<? echo $id; ?>"></td> 
<td><input type="submit" name="Submit" value="Submit" class="button"> <input type="reset" name="Submit2" value="Reset" class="button"></td> 
</tr> 
</table> 
</td> 
</form> 
</tr> 
</table> 
<?php include("../../footer.html");?> 
</div> 
</body> 
</html> 

我重新讀取整個文件現在約10倍,但它仍然保持,說明最終收盤html標記爲意外$結束。我可以忽略一些東西嗎提前致謝。

+0

你能告訴在哪裏線158? –

+0

158行簡直就是 –

+0

這是什麼**/**'if(empty($ view)){'(注意那裏的斜線)? –

回答

4

我相信你有一個無與倫比的{這裏:

<body> 
<?php if(empty($_SESSION['user'])){ 
    include("../../header.html"); 
}else{ 
    include("../../user/user_header.html"); 
} // It looks like this is missing 
?> 
+0

謝謝,我知道我忽略了它。我現在覺得有點蠢,哈哈。 +1 up –

+0

您應該接受答案才能關閉您的問題,而不是或者與您的+1一起使用@JakeBrunton –

+0

對不起,但Stackoverflow不允許您在8分鐘內接受答案。所以,我一直等到明天。請記住這個網站如何對待較不信譽的用戶。 :) –