Jump to content

Code appears on page


gaugeboson

Recommended Posts

[pre]

require("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("footer.php");[/pre]

 

 

This gives me the output:

 

require("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 "" . $row['cat'] . "

"; $entriessql = "SELECT * FROM entries WHERE cat_id = " . $validcat . " ORDER BY dateposted DESC;"; $entriesres = mysql_query($entriessql); $numrows_entries = mysql_num_rows($entriesres); echo "

"; if($numrows_entries == 0) { echo "

No Entries!"; } else { while($entriesrow = mysql_fetch_assoc($entriesres)) { echo "

" . date("D js F Y g.iA", strtotime($entriesrow ['dateposted'])) . " - <a href='viewentry.php?id=" . $entriesrow['id'] . "'>" . $entriesrow['subject'] . ""; } } echo "

" } else { echo "<a href='viewcat.php?id=" . $row['id'] . "'>" . $row['cat'] . "

"; } } require("footer.php");

Link to comment
Share on other sites

Ah, so it is!  That then creates:

 

Parse error: syntax error, unexpected '}', expecting ',' or ';' in C:\xampp\htdocs\viewcat.php on line 44

 

 

 

['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("footer.php");

?>

 

Link to comment
Share on other sites

Parse error: syntax error, unexpected '}', expecting ',' or ';' in C:\xampp\htdocs\viewcat.php on line 44

To be fair, that's a very clear error message.

 

Have you tried scanning around line 44 for a missing ";" which it says it's expecting?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.