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
https://forums.phpfreaks.com/topic/79907-code-appears-on-page/
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
https://forums.phpfreaks.com/topic/79907-code-appears-on-page/#findComment-404748
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.