unsider Posted February 26, 2008 Share Posted February 26, 2008 Error: Parse error: syntax error, unexpected T_EXIT in /home/unsider/www/andy/main.php on line 234 Any more code, info, I'll be glad to post it. <?php if (!@mysql_select_db("mtlc?old")) { echo 'Unable to locate the ' . 'database.'; } if(isset($_POST['commenttext'])) { $commenttext = $_POST['commenttext']; $name = $_POST['name']; $email = $_POST['email']; $sql = "INSERT INTO comments SET commenttext ='$commenttext', commentdate =NOW(), name ='$name', email='$email'"; if (!@mysql_query($sql)) { echo 'Error adding query: ' . mysql_error(); } } echo 'The comments listed in the database...<br>'; $result = @mysql_query('SELECT commenttext, commentdate, name, email FROM comments'); if (!$result) { echo 'Error performing query: ' . mysql_error(); } ?> </div> <div id="comments"> <? echo '<table>'; $tr=1; while ($row = mysql_fetch_array($result)) { echo '<tr class="tr' . $tr . '"><td>' . $row["name"] . ' says: <br>' . $row['commentdate'] . '<br>' . $row['commenttext'] . '</td></tr>'; if($tr==1){ $tr=2; } else if($tr==2){ $tr=1; } } echo '</table>'; echo '<br>'; echo '<a href="' . $_SERVER['PHP_SELF'] . '?addcomment=1">Add comment!</a>'; ?> <? // pagination $t = mysql_query("SELECT * FROM comments WHERE id = '".addslashes($_GET['cat'])."'"); if(!$t) die(mysql_error()); $a = mysql_fetch_object($t); $total_items = mysql_num_rows($t); $limit = $_GET['limit']; $type = $_GET['type']; $page = $_GET['page']; if((!$limit) || (is_numeric($limit) == false) || ($limit < 10) || ($limit > 50)) { $limit = 10; } if((!$page) || (is_numeric($page) == false) || ($page < 0) || ($page > $total_items)) { $page = 1; } $total_pages = ceil($total_items / $limit); $set_limit = $page * $limit - ($limit); $q = mysql_query("SELECT * FROM comments WHERE id = '".addslashes($_GET['cat'])."' LIMIT $set_limit, $limit"); if(!$q) die(mysql_error()); $err = mysql_num_rows($q); if($err == 0) die("No matches met your criteria."); echo(" <a href=main.php?cat=$cat&limit=10&page=1>10</a> | <a href=main.php?cat=$cat&limit=25&page=1>25</a> | <a href=main.php?cat=$cat&limit=50&page=1>50</a>"); while($code = mysql_fetch_object($q)) { echo("item: ".$code->title."<BR>"); } $cat = urlencode($cat); $prev_page = $page - 1; if($prev_page >= 1) { echo("<b><<</b> <a href=http://main.php?cat=$cat&limit=$limit&page=$prev_page><b>Prev.</b></a>"); } for($a = 1; $a <= $total_pages; $a++) { if($a == $page) { echo("<b> $a</b> | "); } else { echo(" <a href=http://main.php?cat=$cat&limit=$limit&page=$a> $a </a> | "); } } $next_page = $page + 1; if($next_page <= $total_pages) { echo("<a href=http://main.php?cat=$cat&limit=$limit&page=$next_page><b>Next</b></a> > >"); } ?> Line 234: $t = mysql_query("SELECT * FROM comments WHERE id = '".addslashes($_GET['cat'])."'"); if(!$t) die(mysql_error()); If above is wrong, then this might be as well. This is a few lines down. $q = mysql_query("SELECT * FROM comments WHERE id = '".addslashes($_GET['cat'])."' LIMIT $set_limit, $limit"); if(!$q) die(mysql_error()); $err = mysql_num_rows($q); if($err == 0) die("No matches met your criteria."); Link to comment https://forums.phpfreaks.com/topic/92996-pagination-parse-error/ Share on other sites More sharing options...
Bauer418 Posted February 26, 2008 Share Posted February 26, 2008 Post line 234 as well as a few lines before and after. Link to comment https://forums.phpfreaks.com/topic/92996-pagination-parse-error/#findComment-476435 Share on other sites More sharing options...
unsider Posted February 26, 2008 Author Share Posted February 26, 2008 K, I've posted the line, I think it may have to do with the tables I'm trying to retrieve data from.. Link to comment https://forums.phpfreaks.com/topic/92996-pagination-parse-error/#findComment-476439 Share on other sites More sharing options...
unsider Posted February 26, 2008 Author Share Posted February 26, 2008 Any ideas? Link to comment https://forums.phpfreaks.com/topic/92996-pagination-parse-error/#findComment-476467 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.