Thread: PHP Problem
View Single Post
01-07-2007, 07:15 PM
#1
Alex Eyre is offline Alex Eyre
Alex Eyre's Avatar
Status: Designer
Join date: Aug 2006
Location: Manchester
Expertise:
Software:
 
Posts: 1,132
iTrader: 5 / 100%
 

Alex Eyre is on a distinguished road

Send a message via MSN to Alex Eyre

  Old  PHP Problem

Hi everyone,
I am trying to get the latest threads to show on this page, but it is failing as you can see:
http://www.wiiroom.net/box.php

For some reason nothing is displaying
Please see if you can spot anything.

and heres the code:

Code:
<?php
$rel = "forum/"; // The directory to your forum--relative to this file's location; include ending slash
chdir($rel);
$host = "localhost"; // Your database host
$user = "****"; // Your database username
$pass = "***"; // Your database password
$data = "wiiroom_board"; // The name of your database
$prfx = "mybb_"; // The table prefix of your database
$col1 = "#FFFFFF"; // The color of the first row--alternating row colours
$col2 = "#FCFCFC"; // The color of the second row
// NOTE: I didn't include ./global.php because I wasn't sure what the variables look like.
$num = 5; // The number of recent posts to show
$author = TRUE; // Should we display the post author? (TRUE or FALSE)

$conn = mysql_connect($host,$user,$pass) or die("<b>Error:</b> Database connection failed.");
$sel = mysql_select_db($data,$conn) or die("<b>Error:</b> Database connection failed.");

if($author == TRUE)
{
?>
<table>
<?php
}
$i = 0;
$q = mysql_query("SELECT * FROM ".$prfx."posts ORDER BY dateline DESC LIMIT ".$num);
while($row = mysql_fetch_array($q))
{
 if($i % 2 == 0)
 {
  $bgcolor = $col1;
 }
 else
 {
  $bgcolor = $col2;
 }
 $i++;
 $q2 = mysql_query("SELECT * FROM ".$prfx."forums WHERE fid = '".$row["fid"]."';");
 $row = mysql_fetch_array($q2);
?>
 <tr>
  <td width="50%" bgcolor="<?php echo $bgcolor; ?>">
<a title="In forum: <?php echo $row["name"]; ?>" href="<?php echo $rel; ?>showthread.php?tid=<?php echo $row["tid"]; ?>&action=lastpost">
<b><?php echo $row["subject"]; ?></b></a></p></td>
<?php
 if($author == TRUE)
 {
?>
  <td width="50%" bgcolor="<?php echo $bgcolor; ?>">by 
<b><a title="<?php echo $row["username"]; ?>'s Profile" href="<?php echo $rel; ?>member.php?action=profile&uid=<?php echo $row["uid"]; ?>">
<?php echo $row["username"]; ?></b></a></td>
<?php
 }
?>
 </tr>
<?php
}
?>
</table>
Alex.