Im at the end of my rope, Ive tried everything and even the slightest change breaks this. Heres my code, tell me what Im doing wrong please! This works, but I notice sometimes the page errors and displays nothing for prolonged periods of time. Im not sure what thats about though.
PHP Code:
<?php
chdir('/home/horror/public_html/forums');
//PluhNews 1.5 released under GNU GPL Licence version 2.0 (see copying.txt file for more info)
//Set your permissions in your control panel to make sure that only YOU and who you specify can post news. Otherwise, everyone and their dog can register and post in your news forums, thus posting where your news will appear. But for this script to work it's extra magic, be sure your members can reply to your news posts.
require($_SERVER['DOCUMENT_ROOT'] . '/news/PluhConfig.php');
require($_SERVER['DOCUMENT_ROOT'] . '/forums/includes/config.php');
//scroll down to edit the HTML for the news
//**********************
//Start the goodies (please do not edit to goodies unless you know what you are doing
//connect
$link = mysql_connect('localhost', '*EDITED*', '*EDITED*');
if (!$link) {
die('Not connected : ' . mysql_error());
}
//select database
$db_selected = mysql_select_db('*EDITED', $link);
if (!$db_selected) {
die ('Can\'t use *EDITED : ' . mysql_error());
}
// create sql statement
$sql = "SELECT threadid, title, forumid, replycount, postusername, postuserid, lastposter, dateline, iconid FROM thread WHERE forumid = \"$newsforums\" ORDER BY threadid DESC LIMIT $newsitems";
//execute sql query
$sql_result = mysql_query($sql, $link) or die ("Could not execute query.");
if (!$sql_result) {
echo "<p>Could not get record.";
}
while ($row = mysql_fetch_array($sql_result)) {
$threadid = $row["threadid"];
$title = $row["title"];
$forumid = $row["forumid"];
$replycount = $row["replycount"];
$postusername = $row["postusername"];
$postuserid = $row["postuserid"];
$lastposter = $row["lastposter"];
$iconid = $row["iconid"];
$dateline = $row["dateline"];
//create the second SQL statement to pull the post from the thread it resides in
$sql2 = "SELECT postid, threadid, username, userid, title, dateline, pagetext, iconid FROM post WHERE threadid = \"$threadid\" ORDER BY postid ASC LIMIT 1";
//execute second sql query
$sql_result2 = mysql_query($sql2, $link) or die ("Could not execute query in second sql statement.");
if (!$sql_result2) {
echo "<p>Could not get record in second statement.";
}
while ($row = mysql_fetch_array($sql_result2)) {
$pagetext = $row["pagetext"];
//gotta convert unix time
$dateposted = date("D j M Y, g:i A",$dateline);
//end the goodies
if ($replycount==1) {
$commenttext = "Comment";
}
else {
$commenttext = "Comments";
}
define('VB_AREA', 'Forum');
define('PLUH_NEWS_FETCH', true);
include_once($_SERVER['DOCUMENT_ROOT'] . '/forums/includes/init.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/forums/includes/class_bbcode.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/forums/includes/class_hook.php');
$parser77 =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$bericht = $parser77->do_parse($pagetext, true);
// **********************
//Edit the HTML here (keep in mind that any double quote that is HTML requires a backslash in front of it)
echo "
<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=14 valign=top background=images/dl-title-side-bg-norm.gif><img src=images/blank.gif width=14></td>
<td background=images/texture-norm.jpg><table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td><br><p><strong><font color=#C19A6B>$title</font></strong><br>
<img src=images/linebreak.gif><br>
<font size=1>Posted on $dateposted by <b>$postusername</b><br></font><br>
$bericht</p><br><br><div align=right>$replycount $commenttext | <a href=$forumspath/showthread.php?s=&threadid=$threadid>View $commenttext</a> | <a href=$forumspath/newreply.php?action=newreply&threadid=$threadid>Post $commenttext</a></div>
</td>
</tr>
<tr>
<td height=1 bgcolor=#6B6B6B><img src=images/blank.gif width=1 height=1></td>
</tr>
</table></td>
<td width=5 background=images/dl-title-side-bg2.gif><img src=images/blank.gif></td>
</tr>
</table>
";
}
}
//add news search stuff (this is optional - delete if you do not wish to include this, or edit it to meet your needs
echo "
<table width=100% border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=14 valign=top background=images/dl-title-side-bg-norm.gif><img src=images/blank.gif width=14></td>
<td background=images/texture-norm.jpg><table width=100% border=0 cellspacing=1 cellpadding=1>
<tr>
<td>
<center><a href=\"forums/search.php?f=2\">Search the News</a> | <a href=\"forums/forumdisplay.php?forumid=2\">View All News Posts</a></center>
</td>
</tr>
</table></td>
<td width=5 background=images/dl-title-side-bg2.gif><img src=images/blank.gif></td>
</tr>
</table>
";
//end HTML edit
//**********************
//disconnect
mysql_free_result($sql_result);
mysql_close($link);
chdir('/home/horror/public_html/');
?>