Jump to content

News section from phpBB3


DarkArchon

Recommended Posts

Ok, what I'm trying to do here is fetch info from a phpBB3 forum and put it up on the front page of my site in a little group of 3. However, I'm having problems (or I wouldn't be here). I believe the problem has something to do with line 10. If I comment it and the brackets with it out I can make it all the way to line 26 before something screams at me, the news.php will also show a good connection at that point.

 

The error it's giving me now can be found at the bottom of my page http://www.orderofatlas.com/as/index.php look for the "Testing goes here!" block. Right now it says the error occurs on line 12, but if you go to news.php it doesn't show an output at all, either failed or good, which indicates to me that it's not making it that far (again, line 10 maybe?). Anyway, I'm hoping someone else here can shed some light on this. I'm probably missing something obvious, but have been staring at it too long to see it.

 

Thanks

 

<?php
// Set variables to connect to server
$Forum = 24;	  
$Host = localhost;
$User = username;
$Password = password;
$Database = database;

// Function for connected to the database
function create_db_connection($Database)
{
  $link = mysqli_connect($Host, $User, $Password, $Database);

   if (!$link)
	{
		printf("\n\nConnect failed: %s\n", mysqli_connect_error());
		exit();
	}
	printf("\n\nHost information: %s\n", mysqli_get_host_info($link));
}

// Fetches X number of rows "notice(3)"
function notice($row)
{
  $Forum;
  create_db_connection("$Database");
          $res = mysqli_query("SELECT topic_id, topic_title, topic_time FROM phpbb_topics WHERE forum_id=$Forum ORDER BY topic_id DESC LIMIT $row");
  
  if (!$res || mysqli_num_rows($res) == 0)
        {
      		echo "<TR><TD VALIGN=\"TOP\" CLASS=maintext><FONT COLOR=#666666 face='Verdana, Arial, Helvetica, sans-serif' size=2>No News Entrys</TD></TR>";
      		return;
    	}

  while (list($id, $topictitle, $topicdate) = mysqli_fetch_row($res) )
	{
		$topicdate = date('M j/y', $topicdate);
		$iconhtml = "";

		echo "<TR>";
		echo "  <TD VALIGN=\"TOP\" CLASS=\"maintext\" WIDTH=75 align=left> <FONT COLOR=#666666 face='Verdana, Arial, Helvetica, sans-serif' size=2>$topicdate</FONT></TD>";
		echo "  <TD VALIGN=\"TOP\" CLASS=\"maintext\" align=left width=4> <!-- was icon html --> </TD>";
		echo "  <TD VALIGN=\"TOP\" CLASS=\"maintext\" ALIGN=left width=215><FONT COLOR=#666666 face='Verdana, Arial, Helvetica, sans-serif' size=2><A HREF=/board/viewtopic.php?t=$id>$topictitle</A></FONT></TD>";
		echo "</TR>";
	}
  mysqli_free_result($res);
}

// Fetches all rows
function all()
{
   	  $Forum;

   	  create_db_connection("$Database");
  $res = mysqli_query("SELECT topic_id, topic_title, topic_time FROM phpbb_topics WHERE forum_id=$Forum ORDER BY topic_id DESC LIMIT 50");

  	  if (!$res || mysqli_num_rows($res) == 0)
    {
        	echo "<TR><TD VALIGN=\"TOP\" ALIGN=\"CENTER\" CLASS=maintext><FONT COLOR=66666 face='Verdana, Arial, Helvetica, sans-serif' size=2>No News Entrys</TD></TR>";
        return;
      	}

  while (list($id,$topictitle,$topicdate) = mysqli_fetch_row($res))
    {
            $topicdate = date('M j Y - h:i A', $topicdate);
        	$iconhtml = " ";

		echo "<TR>"; 
		echo "  <TD CLASS='maintext' align=left><FONT COLOR='666666' face='Verdana, Arial, Helvetica, sans-serif' size=2>$topicdate</FONT></TD>";
		echo "  <TD VALIGN=\"TOP\" CLASS=maintext>$iconhtml</TD>";
		echo "  <TD CLASS='maintext' align=left><FONT face='Verdana, Arial, Helvetica, sans-serif' size=2><A HREF=/board/viewtopic.php?t=$id>".$topictitle."</A></FONT></TD>";
		echo "</TR>";
    }
  mysqli_free_result($res);
}
?>

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.