error message : Parse error: syntax error, unexpected $end in
C:\wamp\www\blog\functions.php on line 490
and the full code are :
do_html_footer();
print_info();
}
}
function view_posting_id($idd)
{
view_menu();
$conn = db_connect();
$result = mysql_query("SELECT * FROM posting WHERE id='".$idd."'");
$row = mysql_fetch_array($result);
$id = $row[0];
$numcomments = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM comments WHERE entryid = '$id'"));
echo stripslashes("<h2>$row[title]</h2>");
$row[message] = parser($row[message]);
echo stripslashes("<p>".nl2br("$row[message]</p>"));
if (isset($_SESSION['validuser']))
echo "<p><a href=\"editentry.php?idd=$row[id]\">Edit post</a></p>";
echo "<h5>Posted: $row[time] | " ;
echo "<a href='comment.php?idd=$id'>Comments: ($numcomments[0])</a></h5>";
}
function view_comments_id($idd)
{
echo "<h2>Komentar</h2>";
$num_links = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM comments"))or die(mysql_error());
if ($num_links[0] == 0)
{
echo "<p>Tidak ada komentar</p>";
} elseif ($num_links[0] > 0)
{
$result = mysql_query("SELECT * FROM comments WHERE entryid=$idd ORDER BY id ASC");
while($row = mysql_fetch_array($result))
{
$row[comment] = parser($row[comment]);
echo stripslashes("<p>$row[comment]<br>");
echo stripslashes("<a href=\"$row[url]\">$row[name]</a> | ");
echo "$row[time]</p>";
}
}
}
function comment_form()
{
$idd = mysql_real_escape_string($_GET['idd']);
$existentry = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM posting WHERE id = '$idd'"));
if ($existentry[0] == 1)
{
echo "
<form action=\"comment.php?idd=$idd&post=1\" method=\"post\">
<h2>Posting Komentar</h2>
<p>Pasangan tag berikut dapat digunakan di dalam komentar: [b][/b] - [i][/i] - [url][/url] - [img][/img]</p>
<table>
<tr><td>Name</td><td><input type=\"text\" name=\"name\" maxlength=\"25\" size=\"40\" value=\"$user_name\" /></td></tr>
<tr><td>Email</td><td><input type=\"text\" name=\"email\" maxlength=\"40\" size=\"40\" value=\"$user_email\" /></td></tr>
<tr><td>Message</td><td><textarea name=\"message\" rows=\"7\" cols=\"40\" ></textarea></td></tr>
</table>
<input type=\"hidden\" name=\"idd\" value=\"$idd\" />
<input type=\"submit\" value=\"Post Comment\" name=\"send\" class=\"submit\" />
</form>
";
} else {
echo "Blog ID tidak ada!";
}
print_info();
}
function view_admin_menu($menu)
{
echo "<div id=\"content\">";
echo "<h5>Login : ".$_SESSION['validuser']." | ";
echo "<a href=\"index.php\">Home</a> | ";
echo "<a href=\"adminmenu.php?menu=1\">Add Entry</a> | ";
echo "<a href=\"adminmenu.php?menu=2\">List Posts</a> | ";
echo "<a href=\"adminmenu.php?menu=3\">Add Link</a> | ";
echo "<a href=\"adminmenu.php?menu=4\">List Links</a> | ";
echo "<a href=\"logout.php\">Logout</a></h5>";
switch ($menu) {
case 1:
form_add_entry();
break;
case 2:
list_all_posting();
break;
case 3:
form_add_link();
break;
case 4:
list_all_link();
break;
}
}
function form_add_entry()
{ ?>
<form action="createnew.php" method="post">
<h2>Post entry baru</h2>
<div id="posting">
<p>Pasangan tag berikut dapat digunakan di dalam komentar: [b][/b] - [i][/i] - [url][/url] - [img][/img]</p>
<table>
<tr><td>Title</td><td><input type="text" name="title" maxlength="80" size="40"></td></tr>
<tr><td>Message</td><td><textarea name="message" rows="10" cols="60"></textarea></td></tr>
</table>
<input type="submit" value="Post Entry" name="send" class="submit">
</form>
<?
print_info();
}
function form_add_link()
{ ?>
<form action="createlink.php" method="post">
<h2>Tambah Link Baru</h2>
<div id="posting">
<table>
<tr><td>Nama</td><td><input type="text" name="name" maxlength="30" size="30"></td></tr>
<tr><td>URL</td><td><input type="text" name="url" maxlength="50" size="40" value="http://"></td></tr>
<tr><td>Keterangan</td><td><input type="text" name="description" maxlength="80" size="40"></td></tr>
</table>
<input type="submit" value="Simpan" name="send" class="submit">
</form>
<?
print_info();
}
function list_all_posting()
{
echo "<h2>Posting</h2>";
echo "<div id=\"Posting\">";
$conn = db_connect();
$num_links = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM posting"))
or die(mysql_error());
if ($num_links[0] == 0)
{
echo "Tidak ada posting";
} elseif ($num_links[0] > 0)
{
$result = mysql_query("SELECT * FROM posting ORDER BY id DESC");
echo "<ul>";
while($row = mysql_fetch_array($result))
{
echo stripslashes("<li>$row[title] |
<a href=\"editentry.php?idd=$row[id]\">Edit</a> |
<a href=\"editentry.php?idd=$row[id]&post=2\">Delete</a></li>");
}
echo "</ul>";
}
print_info();
}
function list_all_link()
{
echo "<h2>Link</h2>";
echo "<div id=\"Posting\">";
$conn = db_connect();
$num_links = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM links"))
or die(mysql_error());
if ($num_links[0] == 0)
{
echo "Tidak ada link";
} elseif ($num_links[0] > 0)
{
$result = mysql_query("SELECT * FROM links ORDER BY id");
echo "<ul>";
while($row = mysql_fetch_array($result))
{
echo stripslashes("<li>$row[name] |
<a href=\"editlink.php?idd=$row[id]\">Edit</a> |
<a href=\"editlink.php?idd=$row[id]&post=2\">Delete</a></li>");
}
echo "</ul>";
}
print_info();
}
function form_edit_entry($idd)
{
echo "<div id=\"posting\">";
echo "<form action=\"editentry.php?idd=$idd&post=1\" method=\"post\">";
echo "<h2>Edit entry</h2>";
echo "<p>Pasangan tag berikut dapat digunakan di dalam komentar: [b][/b] - [i][/i] - [url][/url] - [img][/img]</p>";
echo "<table>";
//ambil isi dari tabel
$conn = db_connect();
$entry = mysql_fetch_row(mysql_query("SELECT title, message FROM posting WHERE id = '$idd'"))
or die(mysql_error());
echo "<tr><td>Title</td><td><input type=\"text\" name=\"title\"
maxlength=\"80\" size=\"40\" value=\"";
echo stripslashes($entry[0]);
echo "\"></td></tr>";
echo "<tr><td>Message</td><td><textarea name=\"message\" rows=\"10\"
cols=\"60\">";
echo stripslashes($entry[1]);
echo "</textarea></td></tr></table>";
echo "<input type=\"submit\" value=\"Save Change\" name=\"send\"
class=\"submit\"></form>";
print_info();
}
function form_link_entry($idd)
{
echo "<div id=\"posting\">";
echo "<form action=\"editlink.php?idd=$idd&post=1\" method=\"post\">";
echo "<h2>Edit Link</h2>";
echo "<table>";
//ambil isi dari tabel
$conn = db_connect();
$entry = mysql_fetch_row(mysql_query("SELECT name, url, description FROM links WHERE id = '$idd'"))
or die(mysql_error());
echo "<tr><td>Nama</td><td><input type=\"text\" name=\"name\"
maxlength=\"30\" size=\"30\" value=\"";
echo stripslashes($entry[0]);
echo "\"></td></tr>";
echo "<tr><td>Url</td><td><input type=\"text\" name=\"url\"
maxlength=\"50\" size=\"50\" value=\"";
echo stripslashes($entry[1]);
echo "\"></td></tr>";
echo "<tr><td>Nama</td><td><input type=\"text\" name=\"description\"
maxlength=\"80\" size=\"80\" value=\"";
echo stripslashes($entry[2]);
echo "\"></td></tr>";
echo "</table>";
echo "<input type=\"submit\" value=\"Save Change\" name=\"send\"
class=\"submit\"></form>";
print_info();
}
function do_html_footer()
{
?>
</body>
</html>
<?
}
function view_menu()
{
echo "<div id=\"content\">";
if (!isset($_SESSION['validuser']))
{
echo "<h5>Login : Guest | ";
echo "<a href=\"index.php\">Home</a> | ";
echo "<a href=\"login.php\">Admin Login</a></h5>";
}
else
{
echo "<h5>Login : ".$_SESSION['validuser']." | ";
echo "<a href=\"index.php\">Home</a> | ";
echo "<a href=\"adminmenu.php\">Admin Menu</a> | ";
echo "<a href=\"logout.php\">Logout</a></h5>";
}
echo "<div id=\"posting\">";
}
function print_info()
{
echo "</div>";
echo "<h4>Powered by: InBlog (c) 2006</h4>";
echo "</div>";
}
function parser($text)
{
$patterns = array("/\[img\](.*?)\[\/img\]/",
"/\[link\](.*?)\[\/link\]/",
"/\[url\](.*?)\[\/url\]/",
"/\[b\](.*?)\[\/b\]/",
"/\[u\](.*?)\[\/u\]/",
"/\[i\](.*?)\[\/i\]/");
$replacements = array("<img src=\"\\1\" alt=\"Image\" />",
"<a href=\"\\1\">\\1</a>",
"<a href=\"\\1\">\\1</a>",
"<strong>\\1</strong>",
"<u>\\1</u>",
"<i>\\1</i>");
$text = preg_replace($patterns,$replacements, $text);
mysql_real_escape_string($text);
return $text;
}
function db_connect()
{
include 'config.php';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ("Failed to connect");
mysql_select_db($dbname, $conn) or die ("Failed to connect!");
return $conn;
}
PLease help me to rebuilt my site. What are the wrong code?