By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,401 Members | 793 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,401 IT Pros & Developers. It's quick & easy.

Parse error: syntax error, unexpected $end in E:\wamp\www\forums\view_topic.php on li

P: 1
I am getting the following error:
Parse error: syntax error, unexpected $end in E:\wamp\www\forums\view_topic.php on line 138
And i am a newbie..
I have been working on the code for ages and now it dosent work!!!

HELP


Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $host="localhost"; // Host name 
  3. $username="root"; // Mysql username 
  4. $password=""; // Mysql password 
  5. $db_name="forum"; // Database name 
  6. $tbl_name="forum_question"; // Table name
  7.  
  8. // Connect to server and select database.
  9. mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
  10. mysql_select_db("$db_name")or die("cannot select DB");
  11.  
  12.  
  13. // get value of id that sent from address bar 
  14. $id=$_GET['id'];
  15.  
  16. $sql="SELECT * FROM $tbl_name WHERE id='$id'";
  17. $result=mysql_query($sql);
  18.  
  19. $rows=mysql_fetch_array($result);
  20. ?>
  21. <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  22. <tr>
  23. <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bordercolor="1" bgcolor="#FFFFFF">
  24. <tr>
  25. <td bgcolor="#F8F7F1"><strong><?php echo $rows['topic']; ?></strong></td>
  26. </tr>
  27.  
  28. <tr>
  29. <td bgcolor="#F8F7F1"><?php echo $rows['detail']; ?></td>
  30. </tr>
  31.  
  32. <tr>
  33. <td bgcolor="#F8F7F1"><strong>By :</strong> <?php echo $rows['name']; ?> <strong>Email : </strong><?php echo $rows['email'];?></td>
  34. </tr>
  35.  
  36. <tr>
  37. <td bgcolor="#F8F7F1"><strong>Date/time : </strong><?php echo $rows['datetime']; ?></td>
  38. </tr>
  39. </table></td>
  40. </tr>
  41. </table>
  42. <BR>
  43. <?php
  44. $tbl_name2="forum_answer"; // Switch to table "forum_answer"
  45.  
  46. $sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'";
  47. $result2=mysql_query($sql2);
  48.  
  49. while($rows=mysql_fetch_array($result2)){
  50. ?>
  51. <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  52. <tr>
  53. <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
  54. <tr>
  55. <td bgcolor="#F8F7F1"><strong>ID</strong></td>
  56. <td bgcolor="#F8F7F1">:</td>
  57. <td bgcolor="#F8F7F1"><?php echo $rows['a_id']; ?></td>
  58. </tr>
  59. <tr>
  60. <td width="18%" bgcolor="#F8F7F1"><strong>Name</strong></td>
  61. <td width="5%" bgcolor="#F8F7F1">:</td>
  62. <td width="77%" bgcolor="#F8F7F1"><?php echo $rows['a_name']; ?></td>
  63. </tr>
  64. <tr>
  65. <td bgcolor="#F8F7F1"><strong>Email</strong></td>
  66. <td bgcolor="#F8F7F1">:</td>
  67. <td bgcolor="#F8F7F1"><?php echo $rows['a_email']; ?></td>
  68. </tr>
  69. <tr>
  70. <td bgcolor="#F8F7F1"><strong>Answer</strong></td>
  71. <td bgcolor="#F8F7F1">:</td>
  72. <td bgcolor="#F8F7F1"><?php echo $rows['a_answer']; ?></td>
  73. </tr>
  74. <tr>
  75. <td bgcolor="#F8F7F1"><strong>Date/Time</strong></td>
  76. <td bgcolor="#F8F7F1">:</td>
  77. <td bgcolor="#F8F7F1"><?php echo $rows['a_datetime']; ?></td>
  78. </tr>
  79. </table></td>
  80. </tr>
  81. </table><br>
  82.  
  83. <?
  84. }
  85.  
  86. $sql3="SELECT view FROM $tbl_name WHERE id='$id'";
  87. $result3=mysql_query($sql3);
  88.  
  89. $rows=mysql_fetch_array($result3);
  90. $view=$rows['view'];
  91.  
  92. // if have no counter value set counter = 1
  93. if(empty($view)){
  94. $view=1;
  95. $sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id='$id'";
  96. $result4=mysql_query($sql4);
  97. }
  98.  
  99.  
  100. // count more value
  101. $addview=$view+1;
  102. $sql5="update $tbl_name set view='$addview' WHERE id='$id'";
  103. $result5=mysql_query($sql5);
  104.  
  105. mysql_close();
  106. ?>
  107.  
  108. <BR>
  109. <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  110. <tr>
  111. <form name="form1" method="post" action="add_answer.php">
  112. <td>
  113. <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
  114. <tr>
  115. <td width="18%"><strong>Name</strong></td>
  116. <td width="3%">:</td>
  117. <td width="79%"><input name="a_name" type="text" id="a_name" size="45"></td>
  118. </tr>
  119. <tr>
  120. <td><strong>Email</strong></td>
  121. <td>:</td>
  122. <td><input name="a_email" type="text" id="a_email" size="45"></td>
  123. </tr>
  124. <tr>
  125. <td valign="top"><strong>Answer</strong></td>
  126. <td valign="top">:</td>
  127. <td><textarea name="a_answer" cols="45" rows="3" id="a_answer"></textarea></td>
  128. </tr>
  129. <tr>
  130. <td>&nbsp;</td>
  131. <td><input name="id" type="hidden" value="<?php echo $id; ?>"></td>
  132. <td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td>
  133. </tr>
  134. </table>
  135. </td>
  136. </form>
  137. </tr>
  138. </table>
The last line in 139
Dec 23 '11 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
that error usually comes up if there is a bracket mismatch (e.g. missing })
Dec 23 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.