944,087 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 3424
  • PHP RSS
Nov 15th, 2005
0

Parse error at last line of page's code

Expand Post »
hi,

I'm using Dreamweaver MX and I've got a problem with 2 pages including repeated zones. I added to these pages a dynamic text, and after this, in test mode I have a parse error at last line of the code. It seemed to me my code was clear.

So I opened these pages with WebExpert, and I saw Dreamweaver added comments in dynamic navigation bar which were breaking php code. I removed them so the code was clear, but in test mode nothing changed and the parse error was still there.

Has somebody an idea to help me ?

Thank's a lot for your time.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
paratge is offline Offline
1 posts
since Nov 2005
Nov 16th, 2005
0

Re: Parse error at last line of page's code

Maybe you can help us by showing the code that you are getting the error with?
Reputation Points: 16
Solved Threads: 7
Junior Poster
Lafinboy is offline Offline
166 posts
since Jul 2004
May 8th, 2010
0

parse error at las line of page's code

hi guys,
Im having the same problem but im using dreamweaver8 instead. bear with me I'm very new at php.
Im trying to insert multiple rows into the same table so I mixed some code I saw online with the code generated in dreamweaver and then when I tried running the page I got the error

Parse error: parse error in C:\wamp\www\student information system\student_list_attendance.php on line 292

line 292 is the last line

here is my code//////////

PHP Syntax (Toggle Plain Text)
  1. <?php require_once('Connections/dbconnect.php'); ?>
  2. <?php
  3. //initialize the session
  4. if (!isset($_SESSION)) {
  5. session_start();
  6. }
  7.  
  8. // ** Logout the current user. **
  9. $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
  10. if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  11. $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
  12. }
  13.  
  14. if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  15. //to fully log out a visitor we need to clear the session varialbles
  16. $_SESSION['MM_Username'] = NULL;
  17. $_SESSION['MM_UserGroup'] = NULL;
  18. $_SESSION['PrevUrl'] = NULL;
  19. unset($_SESSION['MM_Username']);
  20. unset($_SESSION['MM_UserGroup']);
  21. unset($_SESSION['PrevUrl']);
  22.  
  23. $logoutGoTo = "home.php";
  24. if ($logoutGoTo) {
  25. header("Location: $logoutGoTo");
  26. exit;
  27. }
  28. }
  29. ?>
  30. <?php
  31. if (!isset($_SESSION)) {
  32. session_start();
  33. }
  34. $MM_authorizedUsers = "admin";
  35. $MM_donotCheckaccess = "false";
  36.  
  37. // *** Restrict Access To Page: Grant or deny access to this page
  38. function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
  39. // For security, start by assuming the visitor is NOT authorized.
  40. $isValid = False;
  41.  
  42. // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
  43. // Therefore, we know that a user is NOT logged in if that Session variable is blank.
  44. if (!empty($UserName)) {
  45. // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
  46. // Parse the strings into arrays.
  47. $arrUsers = Explode(",", $strUsers);
  48. $arrGroups = Explode(",", $strGroups);
  49. if (in_array($UserName, $arrUsers)) {
  50. $isValid = true;
  51. }
  52. // Or, you may restrict access to only certain users based on their username.
  53. if (in_array($UserGroup, $arrGroups)) {
  54. $isValid = true;
  55. }
  56. if (($strUsers == "") && false) {
  57. $isValid = true;
  58. }
  59. }
  60. return $isValid;
  61. }
  62.  
  63. $MM_restrictGoTo = "admin_login.php";
  64. if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
  65. $MM_qsChar = "?";
  66. $MM_referrer = $_SERVER['PHP_SELF'];
  67. if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  68. if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
  69. $MM_referrer .= "?" . $QUERY_STRING;
  70. $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  71. header("Location: ". $MM_restrictGoTo);
  72. exit;
  73. }
  74. ?>
  75. <?php
  76. $currentPage = $_SERVER["PHP_SELF"];
  77.  
  78. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  79. {
  80. $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
  81.  
  82. switch ($theType) {
  83. case "text":
  84. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  85. break;
  86. case "long":
  87. case "int":
  88. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  89. break;
  90. case "double":
  91. $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  92. break;
  93. case "date":
  94. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  95. break;
  96. case "defined":
  97. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  98. break;
  99. }
  100. return $theValue;
  101. }
  102.  
  103. $editFormAction = $_SERVER['PHP_SELF'];
  104. if (isset($_SERVER['QUERY_STRING'])) {
  105. $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  106. }
  107.  
  108. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "student_details")) {
  109.  
  110. FOREACH($_POST['class_id'] as $row=>$therows)
  111. {
  112. $therows=count($_POST['class_id']);
  113. $student_id=mysql_real_escape_string($_POST['student_id'][$row]);
  114. $class_id=mysql_real_escape_string($_POST['class_id'][$row]);
  115.  
  116. if (empty($student_id)){} else {
  117.  
  118. $insertSQL = sprintf("INSERT INTO attendance (class_id, student_id) VALUES ('".$class_id."','".$student_id."')");
  119.  
  120. mysql_select_db($database_dbconnect, $dbconnect);
  121. $Result1 = mysql_query($insertSQL, $dbconnect) or die(mysql_error());
  122. }}
  123.  
  124. $insertGoTo = "student_list_attendance.php";
  125. if (isset($_SERVER['QUERY_STRING'])) {
  126. $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  127. $insertGoTo .= $_SERVER['QUERY_STRING'];
  128. }
  129. header(sprintf("Location: %s", $insertGoTo));
  130.  
  131. $maxRows_student_list = 5;
  132. $pageNum_student_list = 0;
  133. if (isset($_GET['pageNum_student_list'])) {
  134. $pageNum_student_list = $_GET['pageNum_student_list'];
  135. }
  136. $startRow_student_list = $pageNum_student_list * $maxRows_student_list;
  137.  
  138. mysql_select_db($database_dbconnect, $dbconnect);
  139. $query_student_list = "SELECT student_id, First_name, Last_name FROM student ORDER BY student.student_id";
  140. $query_limit_student_list = sprintf("%s LIMIT %d, %d", $query_student_list, $startRow_student_list, $maxRows_student_list);
  141. $student_list = mysql_query($query_limit_student_list, $dbconnect) or die(mysql_error());
  142. $row_student_list = mysql_fetch_assoc($student_list);
  143.  
  144. if (isset($_GET['totalRows_student_list'])) {
  145. $totalRows_student_list = $_GET['totalRows_student_list'];
  146. } else {
  147. $all_student_list = mysql_query($query_student_list);
  148. $totalRows_student_list = mysql_num_rows($all_student_list);
  149. }
  150. $totalPages_student_list = ceil($totalRows_student_list/$maxRows_student_list)-1;
  151.  
  152. $colname_admin = "-1";
  153. if (isset($_SESSION['MM_Username'])) {
  154. $colname_admin = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
  155. }
  156. mysql_select_db($database_dbconnect, $dbconnect);
  157. $query_admin = sprintf("SELECT admin_Id, first_name FROM `admin` WHERE admin_Id = %s", $colname_admin);
  158. $admin = mysql_query($query_admin, $dbconnect) or die(mysql_error());
  159. $row_admin = mysql_fetch_assoc($admin);
  160. $totalRows_admin = mysql_num_rows($admin);
  161.  
  162. mysql_select_db($database_dbconnect, $dbconnect);
  163. $query_attendance = "SELECT * FROM attendance";
  164. $attendance = mysql_query($query_attendance, $dbconnect) or die(mysql_error());
  165. $row_attendance = mysql_fetch_assoc($attendance);
  166. $totalRows_attendance = mysql_num_rows($attendance);
  167.  
  168. $queryString_student_list = "";
  169. if (!empty($_SERVER['QUERY_STRING'])) {
  170. $params = explode("&", $_SERVER['QUERY_STRING']);
  171. $newParams = array();
  172. foreach ($params as $param) {
  173. if (stristr($param, "pageNum_student_list") == false &&
  174. stristr($param, "totalRows_student_list") == false) {
  175. array_push($newParams, $param);
  176. }
  177. }
  178. if (count($newParams) != 0) {
  179. $queryString_student_list = "&" . htmlentities(implode("&", $newParams));
  180. }
  181. }
  182. $queryString_student_list = sprintf("&totalRows_student_list=%d%s", $totalRows_student_list, $queryString_student_list);
  183. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  184. <html xmlns="http://www.w3.org/1999/xhtml">
  185. <head>
  186. <title>Student Attendace </title>
  187. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  188. <link href="style.css" rel="stylesheet" type="text/css" />
  189. <style type="text/css">
  190. <!--
  191. .style2 {color: #614654}
  192. .style3 {color: #FFFFFF}
  193. -->
  194. </style>
  195. </head>
  196. <body>
  197. <div id="container">
  198.  
  199. <div id="banner"><img src="img/banner.jpg" alt="banner" title="banner" /> </div>
  200. <div id="bannerb">
  201.  
  202. <h1>The London College of Business and Information Technology </h1>
  203. <h1>&nbsp;</h1>
  204. <h1><span class="orange">Student Information Site </span></h1>
  205. <div id="scrolldiv" class="scrolldiv">
  206. <img src="img/New Picture.jpg" width="210" height="57" />
  207. </div>
  208. </div>
  209. <div class="topnav">
  210. <div id="navcontainer">
  211. <ul id="navlist">
  212. <li><a href="home.php">Home</a></li>
  213. <li><a href="student_section.php">Students</a></li>
  214. <li id="active"><a href="admin_section.php">Admin</a></li>
  215. <li><a href="About.html">News/Events</a></li>
  216. <li><a href="http://www.free-css.com/">FAQs</a><a href="http://www.free-css.com/">Contact </a></li>
  217. </ul>
  218. </div>
  219. <div class="clear">&nbsp;</div>
  220. </div>
  221.  
  222. <div id="sidebar">
  223. <h1>Student Attendace </h1>
  224. <div id="menu">
  225. <ul>
  226. <li id="active"><a href="manage_students.php">Up to Manage Students </a></li>
  227. <li><a href="<?php echo $logoutAction ?>">Logout</a></li>
  228. </ul>
  229. </div>
  230. <div class="clear">&nbsp; </div>
  231. <div id="scrolldiv">
  232. <img src="img/Scrolls.jpg" />
  233. </div>
  234. </div>
  235. <div id="student_info">
  236. <h1>Logged in as <span class="orange"><?php echo $row_admin['first_name']; ?></span></h1>
  237. <div id="div" class="stpersonal">
  238. <form action="student_list_attendance.php" method="post" name="class_id_value">
  239. <input name="class_id" type="text" size="5" maxlength="2" />
  240. <input name="submit_class_id" type="button" value="GO" />
  241. </form>
  242.  
  243. <form action="<?php echo $editFormAction; ?>" id="student_details" name="student_details" method="POST">
  244.  
  245. <fieldset>
  246. <table width="100%" border="0">
  247. <tr bgcolor="#FF6600">
  248. <td><span class="style3"> ID No. </span></td>
  249. <td><span class="style3">First Name </span></td>
  250. <td colspan="4"><span class="style3">Last Name </span><span class="style3"></span><span class="style3"></span></td>
  251. </tr>
  252. <?php do { ?>
  253. <tr>
  254. <td><input name="student_id" type="text" value="<?php echo $row_student_list['student_id']; ?>"/></td>
  255. <td><?php echo $row_student_list['First_name']; ?></td>
  256. <td><?php echo $row_student_list['Last_name']; ?></td>
  257. <td><a href="update_ attendance.php?studentid=<?php echo $row_student_list['student_id' ] ;?>">update</a></td>
  258. <td><a href="View_attendace_admin.php?studentid=<?php echo $row_student_list['student_id' ] ;?>">View</a></td>
  259. <td><input name="class_id" type="hidden" id="class_id" value="<?php echo $POST['class_id'];?>" /></td>
  260. </tr>
  261. <?php } while ($row_student_list = mysql_fetch_assoc($student_list)); ?>
  262. </table>
  263. </fieldset>
  264.  
  265. <input type="hidden" name="MM_insert" value="student_details">
  266. <input type="submit" name="Submit" value="Update" />
  267. </form>
  268. <p>&nbsp;</p>
  269. <hr width="100%" />
  270.  
  271. <table width="100%" border="0" cellspacing="1px" cellpadding="1px">
  272. <tr>
  273. <th width="25" scope="row"><div align="left" class="style2"><a href="<?php printf("%s?pageNum_student_list=%d%s", $currentPage, min($totalPages_student_list, $pageNum_student_list + 1), $queryString_student_list); ?>">Next</a></div></th>
  274. <td width="25"><div align="left" class="style2"><a href="<?php printf("%s?pageNum_student_list=%d%s", $currentPage, max(0, $pageNum_student_list - 1), $queryString_student_list); ?>">Previous</a></div></td>
  275. <td width="25"><div align="left" class="style2"><a href="<?php printf("%s?pageNum_student_list=%d%s", $currentPage, 0, $queryString_student_list); ?>">First</a></div></td>
  276. <td width="25"><div align="left" class="style2">
  277. <a href="<?php printf("%s?pageNum_student_list=%d%s", $currentPage, $totalPages_student_list, $queryString_student_list); ?>">Last</a></div></td>
  278. </tr>
  279. </table>
  280. </div>
  281. </div>
  282. <div id="footer"> <a href="http://www.free-css.com/">disclaimer</a> | <a href="mailto:denise@mitchinson.net">terms of use </a> | <a href="http://validator.w3.org/check?uri=referer">privacy notice </a> | <a href="http://jigsaw.w3.org/css-validator">Phone: +44 (0) 7533856123 </a> | &copy; 2010 The College| Design by <a href="http://www.mitchinson.net">Jere M F Limited </a></div>
  283. </div>
  284. </body>
  285. </html>
  286. <?php
  287. mysql_free_result($student_list);
  288.  
  289. mysql_free_result($admin);
  290.  
  291. mysql_free_result($attendance);
  292. ?>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
php-coder is offline Offline
4 posts
since May 2010
May 8th, 2010
1
Re: Parse error at last line of page's code
Hi there, this error usually means you're missing a closing curly brace in your code somewhere.

Php-coder, your unclosed curly brace is on line 108. Just glancing at your code, it looks like you'd want to put the closing brace around line 130, under this line.
PHP Syntax (Toggle Plain Text)
  1. header(sprintf("Location: %s", $insertGoTo));
May I also suggest you add an exit; after that line. This stops any more code from being processed when you're doing a redirect.
Last edited by MVied; May 8th, 2010 at 1:05 pm.
Reputation Points: 21
Solved Threads: 11
Junior Poster
MVied is offline Offline
111 posts
since Aug 2008
May 8th, 2010
0
Re: Parse error at last line of page's code
Hi
Mvied, Thanx a lot. I followed your advice and now the error's gone. The page is diplaying but I havn't been able to make the multiple insert work, do you (or any one) think you could help with that too
Last edited by php-coder; May 8th, 2010 at 3:12 pm. Reason: wanted to extend the question to everyone else
Reputation Points: 10
Solved Threads: 0
Newbie Poster
php-coder is offline Offline
4 posts
since May 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: check if session exists to access a directory
Next Thread in PHP Forum Timeline: Headers already sent





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC