Ok after I corrected the query to match my database it still doesn't work for some reason it doesn't want to show up I will break down the complete files that way everyone knows. And Sorry for the long post
here is the index.php file that should call the templeates:
PHP Code:
<?php
//set title
$title = "PatrickMcDaniel.net - Made of 1% content, 99% \"Miscellaneous\"";
$templatesused="'main_head','main_index','news_header','news_main','news_footer','main_footer'";
//get the global file
include ("global.php");
// Get date
$today = date("F j, Y");
//This will select topics from the topics table listing in descending order by the topic ID(tid)
$sql = "SELECT * FROM $topics_table WHERE forum_id='$newsid' order by tid desc";
$sql_topic = mysql_query($sql) or print mysql_error();
// Get header template
eval("\$head = \"".gettemplate('main_head')."\";");
// Get main index template
eval("\$index = \"".gettemplate('main_index')."\";");
//Get news header
eval("\$newheader = \"".gettemplate('news_header')."\";");
//Creates the while loop
while($topic = mysql_fetch_array($sql_topic))
{
$news_sql = mysql_query("select * from $posts_table WHERE topic_id='$topic[tid]' order by pid asc");
$post=mysql_fetch_array($news_sql);
$date = date ("D, j M Y h:i A" ,$post["post_date"]);
//Get news body
eval("\$news = \"".gettemplate('news_main')."\";");
}
//get news footer
eval("\$newfooter = \"".gettemplate('news_footer')."\";");
//Get page footer
eval("\$footer = \"".gettemplate('main_footer')."\";");
?>
Here is the global file :
PHP Code:
<?php
// Get the config file
include ("admin/config.php");
// Get the templates cached
$templatequeries=mysql_query("SELECT title,template FROM template WHERE title IN ($templatesused)" ) or
die (mysql_error());
while($templatequery=mysql_fetch_array($templatequeries)) {
$templates["$templatequery[templatename]"]=$templatequery['template'];
}
unset($templatequery,$templatesused);
mysql_free_result($templatequeries);
// Get the functions file
include ("admin/functions.php");
?>
Here is the functions file:
PHP Code:
<?php
/////////////////// Start Gettemplate //////////////////
function gettemplate($templatename) {
global $templates;
if(!empty($templates["$templatename"])) {
$template=$templates["$templatename"];
}
else {
$gettemplates=mysql_query("SELECT title FROM template WHERE title='$templatename'" ) or
die (mysql_error());
$gettemplate=mysql_fetch_array($gettemplates);
$template=$gettemplate['template'];
}
return addslashes($template);
}
?>
And here is the config file:
PHP Code:
<?php
/////////////////////////////////////////
// CONFIG FILE
/////////////////////////////////////////
//Database variables
$server = ""; //MySQL Server
$username = ""; //Database Username
$password = ""; //Database Password
$database = ""; //Database Name
//IBF information
$topics_table = "ibf_topics"; //Name of the topics table
$posts_table = "ibf_posts"; //Name of the posts table
$newsid = "10"; //News forums ID
// Connect to the database
mysql_connect($server, $username, $password)
or die("Could not connect: " . mysql_error());
mysql_select_db($database)
or die("Could not select db: " . mysql_error());
?>
And if you want to see what happens go to www.patrickmcdaniel.net/index.php I can not for the life of me figuare out what is wrong it looks like good code and I know the templates are there and I get no errors so I have no clue.
Bookmarks