PDA

View Full Version : problem with include and showing data


HEki
10-25-2005, 12:56 PM
hey people,

i have a problem with showing some data on my site.

http://www.clan-sun.com/index-zone.php
when i include this file on my index.php i get this error:
Fatal error: Cannot redeclare class template in /home/clansun/public_html/template_engine.php on line 30

and i realy dont know what to do :verymad:

PsychoticDude85
10-25-2005, 01:07 PM
Paste code here -> http://pastebin.com/

Could be a path problem if it only happens on includes.

HEki
10-25-2005, 01:10 PM
hey psychoticdude :D

what those that link do?

PsychoticDude85
10-25-2005, 01:12 PM
I mean post the code for your php page, since I cannot see the php code it would need to be posted there so I can see if it is an error in the php part of the coding.

HEki
10-25-2005, 01:16 PM
Ok

this is the index-zone.php which is being included on the index.php

<?
/***************************************************************************
*
* This code is free software; you may use, modify or distribute
* it under the GPL (version 2 or later).
*
***************************************************************************/

$debug= @$_GET['debug'];

// ~~ Include necessary files ~~
include('functions.php');
include('template_engine.php');

if($debug) {
$index_starttime= microtime_float();
echo "\n<!--"."Start $index_starttime ms . -->";
}

$template = new Template;

include('connect.php');

getZoneRatings('players-aoa.txt','ratingmember','aoa_members',$dbzonerating[link], 6);

getZoneRatings('players-trial.txt','ratingtrial','aoa_trials',$dbzonerating[link], 2);

if($debug) {
$runningtime= microtime_float()-$index_starttime;
echo "\n<!--"."$runningtime ms read ratings. -->";
}

// ~~ Assign the template file ~~
$template->set_filenames(array(
'template' => 'template.htm' )
);

// ~~ Output the data to the template ~~
$template->pparse('template');

if($debug) {
$runningtime= microtime_float()-$index_starttime;
echo "\n<!--"."$runningtime ms Finished page. -->";
}

?>

strong is where the problem is ...

HEki
10-25-2005, 01:20 PM
uf no
wrong file wait pls

i have to upload it so you can download it

www.clan-sun.com/template_engine.zip
here

PsychoticDude85
10-25-2005, 01:24 PM
Just post the code at http://pastebin.com/ :P It will syntax highlight the code as well as allow me to edit your code directly from the site.

HEki
10-25-2005, 01:25 PM
http://pastebin.com/405720

this is what you want?

PsychoticDude85
10-25-2005, 01:32 PM
For the file you are calling the file into, is there another file linked to that calls "class Template"?

If it says this already I could see that causing the error.

HEki
10-25-2005, 01:35 PM
well this is how it is done:
index.php includes ----> index-zone.php which includes than functions.php and template_engine.php

so how should i do this? couse if i link to index-zone.php it works :d

PsychoticDude85
10-25-2005, 01:38 PM
Well do index.php, functions.php or template_engine.php (all that are above include('index-zone.php');) have "class Template {"

I think the error is being triggered by an earlier file defining it already.

HEki
10-25-2005, 01:40 PM
sorry i am lost ...
:( i dont understand ..

HEki
10-25-2005, 03:12 PM
well wuhuhu i did it. i made a page roster.php and put an iframe on it and load that index-zone.php into that frame ;) it works but it is far from perfect :)

ok another thing is this:
i have a page that sorts members by their ratings. highest rating is first place ... but it only shows names ... i would like to show by names also their ratings ...

so
<?php

$clan="AOA";

/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/

require ('template_engine.php');
$template = new Template;

//
// Load templates
//
$template->set_filenames(array(
'body' => 'template_topfive.html')
);

// member ratings and trial names

$topn= intval(@$_REQUEST['topn']);
if(!$topn) {
$topn= 5;
}

require ('connect.php');

$query= "select * from zone_ratings where clan_castle='aoa_members' order by rating desc LIMIT 0, $topn";
if( $result= mysql_query($query, $dbzonerating[link]) ) {

while($zonerating= mysql_fetch_array($result)) {
$template->assign_block_vars('members', array(
'name' => $zonerating[zonename],
'rating' => $zonerating[rating])
);
}
} else {
echo "\n<!--DEBUG ".mysql_error($dbzonerating[link])."-->";
}

$template->assign_vars( array(
'topn' => $topn,
'clan' => $clan
)
);

$query= "select * from zone_ratings where clan_castle='aoa_trials' order by rating desc";
if( $result= mysql_query($query, $dbzonerating[link]) ) {

while($zonerating= mysql_fetch_array($result)) {
$template->assign_block_vars('trials', array(
'name' => $zonerating[zonename],
'rating' => $zonerating[rating])
);
}
} else {
echo "\n<!-- DEBUG ".mysql_error($dbzonerating[link])."-->";
}


$template->pparse('body');

?>

HEki
10-25-2005, 03:14 PM
html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta http-equiv="Content-Style-Type" content="text/css">

<title>Se7eN Clan</title>

</head>
<body>
<table border=0 width="230" cellspacing=0 cellpadding=0>
<tr>
<td width="115" ><table border=0 cellpaddding=0 cellspacing=0 width="100%" height="100%">
<!-- BEGIN members -->
<tr height="20%"><td align="left"><A target="_blank" alt="Zone rating {members.rating}" title="Zone rating {members.rating}"><b><u>{members.name}</u></b></A></td>
</tr>
<!-- END members -->
</table></td>
<td width="115" align="left">

<table border=0 cellpaddding=0 cellspacing=0 width="61%" height="100%">
<!-- BEGIN members -->
<tr height="20%"><td align="center" class="{ratingmember.CLASS}"><A target="_blank" alt="Zone rating {members.rating}" title="Zone rating {members.rating}"><b><u>{ratingmember.RATING}</u></b></A></td>
</tr>
<!-- END members -->
</table></td>
</tr>
</table>


</body>

</html>

this is html ... so what do i have to add here on a html so that points will also be added?? i was looking in

<body>
<table width="81%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<th height="37" colspan="7"><span class="style7"><font color="#ffffff"><A name="aoa">Full</A>
members</font></span></th>
</tr>
<tr>
<td width="18%"><span class="style4"><font color="#ffffff">ZoneName</font></span></td>
<td width="12%">
<div align="center" class="style4"><font color="#ffffff">Rating</font></div></td>
<td width="15%">
<div align="center" class="style4"><font color="#ffffff">Games</font></div></td>
<td width="10%">
<div align="center" class="style4"><font color="#ffffff">Wins</font></div></td>
<td width="14%">
<div align="center" class="style4"><font color="#ffffff">Losses</font></div></td>
<td width="15%">
<div align="center" class="style4"><font color="#ffffff">Incompletes</font></div></td>
<td width="16%" cellspacing="1">
<div align="center" class="style4"><font color="#ffffff">Win Percent </font></div></td>
</tr>
<!-- BEGIN ratingmember -->
<tr>
<td class="{ratingmember.CLASS} style8">{ratingmember.NICK}</td>
<td class="{ratingmember.CLASS}">
<div align="center" class="style8">{ratingmember.RATING}</div></td>
<td class="{ratingmember.CLASS}">
<div align="center" class="style8">{ratingmember.GAMES}</div></td>
<td class="{ratingmember.CLASS}">
<div align="center" class="style8">{ratingmember.WINS}</div></td>
<td class="{ratingmember.CLASS}">
<div align="center" class="style8">{ratingmember.LOSSES}</div></td>
<td class="{ratingmember.CLASS}">
<div align="center" class="style8">{ratingmember.INCOMP}</div></td>
<td class="{ratingmember.CLASS}">
<div align="center" class="style8">{ratingmember.WINPERCENT}</div></td>
</tr>
<!-- END ratingmember --><tr>
<th height="37" colspan="7"><span class="style7"><font color="#ffffff"><A name="trial">Smurff</A>
members</font></span></th>
</tr>
<tr>
<td width="18%"><span class="style9"><font color="#ffffff">ZoneName</font></span></td>
<td width="12%">
<div align="center" class="style9"><font color="#ffffff">Rating</font></div></td>
<td width="15%">
<div align="center" class="style9"><font color="#ffffff"> Games</font></div></td>
<td width="10%">
<div align="center" class="style9"><font color="#ffffff">Wins</font></div></td>
<td width="14%">
<div align="center" class="style9"><font color="#ffffff">Losses</font></div></td>
<td width="15%">
<div align="center" class="style9"><font color="#ffffff">Incompletes</font></div></td>
<td width="16%" cellspacing="1">
<div align="center" class="style9"><font color="#ffffff">Win Percent </font></div></td>
</tr>
<!-- BEGIN ratingtrial -->
<tr>
<td class="{ratingtrial.CLASS} style6">{ratingtrial.NICK}</td>
<td class="{ratingtrial.CLASS}">
<div align="center" class="style6">{ratingtrial.RATING}</div></td>
<td class="{ratingtrial.CLASS}">
<div align="center" class="style6">{ratingtrial.GAMES}</div></td>
<td class="{ratingtrial.CLASS}">
<div align="center" class="style6">{ratingtrial.WINS}</div></td>
<td class="{ratingtrial.CLASS}">
<div align="center" class="style6">{ratingtrial.LOSSES}</div></td>
<td class="{ratingtrial.CLASS}">
<div align="center" class="style6">{ratingtrial.INCOMP}</div></td>
<td class="{ratingtrial.CLASS}">
<div align="center" class="style6">{ratingtrial.WINPERCENT}</div></td>
</tr>
<!-- END ratingtrial -->
<tr>
<td colspan="7" class="copyright">
<div align="center"><a href="http://cloudmods.fopt-clan.de">&copy; CloudMods</a></div></td>
</tr>
</table>
</body>

this is the code that shows everything ... name, ratings, games, wins, loses, incs, streak ...