Witam, mam dosyć dziwny problem ze Smarty. Mianowicie w bazie jest zapisany tylko jeden testowy post, a Smarty dodaje do tego cztery inne z dziwnymi cyframi:
Kod szablonu:
{config_load file="main.conf" section="conf_index"}
{include file="header.tpl"}
<h1>Forum</h1>
{nocache}
{if isset($smarty.session.login)}
{foreach from=$data item=posty}
<table class="post">
<thead>
<tr>
<td class="postuser">{$posty.name}</td>
<td>{$posty.date}</td>
</tr>
</thead>
<tbody>
<tr>
<td>
{if $posty.avatar != ''}
<img class="userimage" src="{$posty.avatar}" alt="Obrazek użytkownika" />
{/if}
<ul class="about">
<li>Ostatnio wizyta: {$posty.lastenter}</li>
<li>Postów: {$posty.postcount}</li>
</ul>
</td>
<td class="postcontent">
{$posty.content}
<hr />
<div class="postdescription">{$posty.description}</div>
</td>
</tr>
</tbody>
</table>
{/foreach}
{else}
<div style="width: 100%; text-align: center;">
<h2>To forum jest przeznaczone wyłącznie dla osób zarejestrowanych</h2>
<img src="images/lock.png" alt="Zablokowane przez administratora" /></div>
{/if}
{/nocache}
{include file="footer.tpl"}
index.php:
if ($_GET['page']=='' || !is_numeric($_GET['page'])) {
$page = PagesCount($config['postsperpage']);
}
else{
$page['page'] = $_GET['page'];
}
if (IsUserLogged())
{
$data = GetPosts(($page * 10) - 10, $config['postsperpage'], true);
$smarty->assign('data', $data);
}
$smarty->display("index.tpl");
fragment functions.php:
function GetPosts($start, $count, $userinfo)
{
$q = "SELECT `id`, `user`, `date`, `content`, `description`, `lastmodify` FROM `posts` ORDER BY `date` ASC LIMIT " . $start . ", " . $count;
$r = mysql_query($q);
// List posts
$i = 0;
while ($c = mysql_fetch_row($r)){
$i = $i + 1;
$posts[$i]['id'] = $c[0];
$posts[$i]['user'] = $c[1];
$posts[$i]['date'] = $c[2];
$posts[$i]['content'] = $c[3];
$posts[$i]['description'] = $c[4];
$posts[$i]['lastmodify'] = $c[5];
if ($userinfo)
{
$uinfo = GetUserInfo($c[1]);
$posts[$i]['name'] = $uinfo['name'];
$posts[$i]['postcount'] = UserPostCount($c[1]);
$posts[$i]['avatar'] = $uinfo['avatar'];
$posts[$i]['lastenter'] = $uinfo['lastenter'];
$posts['weightbegin'] = $uinfo['weightbegin'];
$posts['weightnow'] = $uinfo['weightnow'];
$posts['weightend'] = $uinfo['weightend'];
$posts['sygn'] = $uinfo['sygn'];
}
}
return $posts;
}
Bez Smarty skrypt functions.php działa już sobie dobre pół roku. W czym leży problem?