Can someone help me with the code, it will not // Filter out HTML code, use // Hyperlinks and all the codings like dont work either. Has some one a clue of what I'm saying (I'm a newbie first class 😃 )
<!-- jokelist.php -->
<HTML>
<HEAD>
<TITLE> Manage Jokes </TITLE>
</HEAD>
<BODY>
<H1>Manage Jokes</H1>
<P><A HREF="jokes.php">New Search</A></P>
<?php
$dbcnx = @mysql_connect("localhost", "drklauw", "");
mysql_select_db('drklauw_nl_db');
// The basic SELECT statement
$select = "SELECT DISTINCT ID, JokeText";
$from = " FROM Jokes";
$where = " WHERE ID > 0";
if ($aid != "") { // An author is selected
$where .= " AND AID=$aid";
}
if ($cid != "") { // A category is selected
$from .= ", JokeLookup";
$where .= " AND ID=JID AND CID=$cid";
}
if ($searchtext != "") { // Some search text was specified
$where .= " AND JokeText LIKE '%$searchtext%'";
}
?>
<TABLE BORDER=1>
<TR><TH>Joke Text</TH><TH>Options</TH></TR>
<?php
$jokes = mysql_query($select . $from . $where);
if (!$jokes) {
echo("</TABLE>");
echo("<P>Error retrieving jokes from database!<BR>".
"Error: " . mysql_error());
exit();
}
while ($joke = mysql_fetch_array($jokes)) {
echo("<TR>\n");
$id = $joke["ID"];
$joketext = $joke["JokeText"];
echo("<TD>$joketext</TD>\n");
echo("<TD>[<A HREF='editjoke.php?id=$id'>Edit</A>|".
"<A HREF='deletejoke.php?id=$id'>Delete</A>]</TD>\n");
echo("</TR>\n");
}
?>
</TABLE>
<?php
// Get the joke text from the database
$joke = mysql_query("SELECT JokeText FROM Jokes ".
"WHERE ID=$id");
$joke = mysql_fetch_array($joke);
$joketext = $joke["JokeTExt"];
// Filter out HTML code
$joketext =htmlspecialchars($joketext);
// If no page specified, default to the
// first page ($page = 0)
if (!isset($page)) $page = 0;
// Split the text into an array of pages
$textarray=split("\[PAGEBREAK]",$joketext);
// Select the page we want
$joketext=$textarray[$page];
// Bold and italics
$joketext = eregi_replace("\[b]","<B>",$joketext);
$joketext = eregi_replace("\[eb]","</B>",$joketext);
$joketext = eregi_replace("\[i]","<I>",$joketext);
$joketext = eregi_replace("\[ei]","</I>",$joketext);
// Paragraphs and line breaks
$joketext = ereg_replace("\r"," ",$joketext);
$joketext = ereg_replace("\n\n","<P>",$joketext);
$joketext = ereg_replace("\n","<BR>",$joketext);
// Hyperlinks
$joketext = ereg_replace(
"\[L] ([-_./a-zA-Z0-9!&%#?,'=:~]+)\[EL]",
"<A HREF=\"\\1\">\\1</A>", $joketext);
$joketext = ereg_replace(
"\[L=([-_./a-zA-Z0-9!&%#?,'=:~]+)]".
"([-_./a-zA-Z0-9 !&%#?,'=:~]+)\[EL]",
"<A HREF=\"\\1\">\\2</A>", $joketext);
if ($page != 0) {
$prevpage = $page - 1;
echo ("<P><A HREF=\"$PHP_SELF?id=$id&page=$prevpage\">".
"Previous Page</A></P>");
}
echo( "<P>$joketext" );
if ($page < count($textarray) -1) {
$nextpage = $page + 1;
echo("<P><A HREF=\"$PHP_SELF?id=$id&page=$nextpage\">".
"Next Page</A></P>");
}
?>
</BODY>
</HTML>