PDA

View Full Version : Including a PHP file


Mad_Griffith
11-06-2005, 10:03 AM
Hi, I need to include the following code contained in a file (I don't even know if the code itself is correct) in the template, what is the correct php code to insert in the template?


<?php
require("./forums/global.php");
$fid = "29"; // The id of the forum to pull posts from goes here

$query = $db->query("SELECT * FROM ".TABLE_PREFIX."threads WHERE fid='$fid' ORDER BY `tid` DESC LIMIT 0,10");
while ($item = $db->fetch_array($query)) {
if (strlen($item['subject']) > 33) { $subject = substr($item['subject'], 0, 32)."..."; } else { $subject = $item['subject']; }
$tid = $item['tid'];
$subject = stripslashes($subject);

$data = $item["dateline"];
$data = mydate("d/m", $data);

echo "<style type=\"text/css\">
<!--
.style3 {
color: #CCCCCC;
font-size: 9px;
font-family: Verdana;
font-weight: bold;
}

.style1 {
color: #FFFFFF;
font-size: 9px;
font-family: Verdana;
font-weight: bold;
}
-->
</style>
<body STYLE=\"background-color:transparent\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td><div align=\"left\">
<!--<li style=\"color:#999999\" type=\"square\">--><span class=\"style1\">$data</span> <a href=\"http://www.unprogged.com/showthread.php?tid=$tid\" target=\"_parent\" class=\"style3\">$subject</a></li>
</li>
</div></td>
</tr>
</table></body>";
}
?>


Thank you

Brian
11-06-2005, 01:35 PM
You can't inlcude PHP in a template. You would either need to add that as a PHP file page or module.

Our Sponsors
 

Mad_Griffith
11-06-2005, 09:50 PM
I've created the module (the .php file linked to it contains the code I posted previously), but it doesn't work, showing some error. Is there a guide anywhere to create a working .php file for a module?

thank you

Brian
11-07-2005, 01:00 PM
Knowing what the error is that it's showing might be helpful.

Our Sponsors
 

Mad_Griffith
11-07-2005, 01:25 PM
here it is:

Warning: main(./forums/global.php): failed to open stream: No such file or directory in /modules/topics_usciterecenti.php on line 2

Fatal error: main(): Failed opening required './forums/global.php' (include_path='.:/php/lib/php/') in /web/htdocs/www.unprogged.com/home/forums/modules/topics_usciterecenti.php on line 2

Brian
11-07-2005, 01:30 PM
Remove this line from your code:
require("./forums/global.php");