Jump to content

Archived

This topic is now archived and is closed to further replies.

ChrisLawrie

Help creating a table???

Recommended Posts

Hi all i need help!

 

I am trying to create a table of 10 latest posts from my forums on the first page of my site. I have tried the following code but errors occur:

 

<h1>LAST 10 POSTS</h1>

<table border=\"1\">

<tr>

<td class=\"white\"><strong>Topic ID</strong></td>

<td class=\"white\"><strong>Topic Title</strong></td>

<td class=\"white\"><strong>Topic Time</strong></td>

<td class=\"white\"><strong>Topic Views</strong></td>

<td class=\"white\"><strong>Forum ID</strong></td>

<td class=\"white\"><strong>Forum Name</strong></td>

<td class=\"white\"><strong>User Name</strong></td>

</tr>

<?php

mysql_pconnect(\"localhost\",\"***\",\"***\");

$query=\"SELECT topic_id, topic_title, topic_time, topic_views, t.forum_id, f.forum_name, u.uname FROM \".$mpnTables.\" t, \".$mpnTables.\" f, \".$mpnTables.\" u where (f.forum_id=t.forum_id) and (forum_type \'1\') and (t.last_post=u.uid) ORDER BY topic_time desc LIMIT 10\";

$result=mysql_db_query(\"***\",$query);

while($row=mysql_fetch_row($result)){

?>

<tr>

<td class=\"white\"><?php print($row[0]);?></td>

<td class=\"white\"><?php print($row[1]);?></td>

<td class=\"white\"><?php print($row[2]);?></td>

<td class=\"white\"><?php print($row[3]);?></td>

<td class=\"white\"><?php print($row[4]);?></td>

<td class=\"white\"><?php print($row[5]);?></td>

<td class=\"white\"><?php print($row[6]);?></td>

</tr>

<?php

}

mysql_free_result($result);

?>

</table>

 

Gives following errors:

 

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in ***/index2.php on line 170

 

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in ***/index2.php on line 183

 

Any suggestions anyone?

My tables are called: mpn_topics, mpn_forums,mpn_users.

 

Cheers

Share this post


Link to post
Share on other sites

The porblem is in the query

 

Try this

 

$result=mysql_db_query("***",$query) 

or die(mysql_error());

 

You will get an idea what the error is.

Share this post


Link to post
Share on other sites

×

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.