I'm only learning PHP, and have encountered some problems that I'm sure are issues newbies often encounter. Nevertheless, I need help. I'm writing code for a simple Weblog forum and one of the problems I've encountered comes on a page entitled viewcat.php. To me, the code looks good. But I receive an error at the end: Parse error: syntax error, unexpected $end in /Users/laurenyoung/Sites/blogtastic/viewcat.php on line 52

Here's the code:

<?php
require("includes/config.php");

if(isset($_GET['id']) == TRUE) {
	if(is_numeric($id) == FALSE) {
	$error = 1;
if($error == 1) {
	header("Location: " . $config_basedir . "/viewcat.php");
}
else {
	$validcat = $_GET['id'];
}
	}
else {
	$validcat = 0;
}

$sql = "SELECT * FROM categories";
$result = mysql_query($sql);

while($row = mysql_fetch_assoc($result)) {
	if($validcat == $row['id']) {
		echo "<strong>" . $row['cat'] . "</strong><br />";
		
		$entriessql = "SELECT * FROM entries WHERE cat_id = " . $validcat .
					" ORDER BY dateposted DESC;";
		$entriesres = mysql_query($entriessql);
		$numrows_entries = mysql_num_rows($entriesres);
		
		echo "<ul>";
		
		if($numrows_entries == 0) {
			echo "<li>No entries!</li>";
			}
			else {
				while($entriesrow = mysql_fetch_assoc($entriesres)) {
					echo "<li>" . date("D jS F Y g.iA", strtotime($entriesrow
						['dateposted'])) .
						" - <a href='viewentry.php?id=" . $entriesrow['id'] . "'>" . 
						$entriesrow['subject'] ."</a></li>";
						}
			}
			echo "</ul>";
	}
	else {
		echo "<a href='viewcat.php?id=" . $row['id'] . "'>" . $row['cat'] .
		"</a><br />";
		}
	}
require("includes/footer.php");
?>

Line 52 is the end. But I don't understand why I would be receiving an error. Any help would be greatly appreciated.

if(isset($_GET) == TRUE) { Brace is not closed for that condition. One suggestion, Indent your code. You can easily find these kinda errors.

Cheers,
Naveen

This article has been dead for over six months. Start a new discussion instead.