Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

tpl acusa erro de index

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Portuguese
View previous topic :: View next topic  
Author Message
trevieri
Smarty n00b


Joined: 26 Apr 2007
Posts: 4

PostPosted: Wed Nov 09, 2011 12:45 pm    Post subject: tpl acusa erro de index Reply with quote

Ao acessar o script main(index.php), nao da erro nenhum, ja qdo tento mostrar o conteudo de uma noticia por completo da erro; onde sera que estou errando?

segue meus arquivos:

index.php
Code:

<?php
 include('uteis/conexao.php');
 
 if(!isset($_POST['ac'])) {
  $ac = 0;
  $ins = "select * from noticias order by data_hora desc limit 7";
 } else {
  $num = $_POST['id'];
  $ac  = $_POST['ac'];
  $ins = "select * from noticias where id='$num' limit 1";
 }

 $con->query($ins);
 $sql = $con->sql;
 $num_lin = mysql_num_rows($sql);

 if($num_lin > 0) {
  $erro = 0;
 } else {
  $erro = 1;
 }

 if($ac==0 && $erro==0) {
  for($i=0; $i<$num_lin; $i++) {
   $array_ids[]     = mysql_result($sql,$i,"id");
   $array_titulos[] = utf8_encode(mysql_result($sql,$i,"titulo"));
   $array_textos[]  = utf8_encode(mysql_result($sql,$i,"texto"));
   $array_datas[]   = mysql_result($sql,$i,"data_hora");
  }
 } else {
  if($erro==0) {
   $vetor = mysql_fetch_array($sql);
  }
 }

 unset($sql);
 $con->Desconecta();
 require('../smarty/libs/Smarty.class.php');
 $smarty = new Smarty;

 if($ac==0 && $erro==0) {
  $smarty->assign("ids", $array_ids);
  $smarty->assign("titulos", $array_titulos);
  $smarty->assign("textos", $array_textos);
  $smarty->assign("datas", $array_datas);
 } else {
  if($erro==0) {
   $smarty->assign("id",     $vetor['id']);
   $smarty->assign("titulo", utf8_encode($vetor['titulo']));
   $smarty->assign("texto",  utf8_encode($vetor['texto']));
   $smarty->assign("data",   $vetor['data_hora']);
  } else {
   $smarty->assign("titulo", "Erro");
   $smarty->assign("texto", "Nenhum registro encontrado");
   $smarty->assign("data", date("y-m-d h:i:s"));
  }
 }

 switch($ac) {
  case '0'    : $smarty->display("index.tpl");
                break;
  case 'show' : $smarty->display("mostra_noticias.tpl");
                break;
 }
?>


index.tpl:
Code:

{config_load file="index.conf" section="Margens"}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>

<body><font face="{#fonteFace#}">

<div align="center">
<form method="POST" action="index.php" name="frm1">
 <input type=hidden name=mod value="978AB">
 <input type=hidden name=id  value="21CAD">
 <input type=hidden name=ac  value="2BC1G">
</form>
<table border="0" cellspacing="0" width="60%">
 <tr>
  <td width="50%" bgcolor="{#corTab#}">
   <font size="5">Confira as &uacute;ltimas not&iacute;cias!</font>
  </td>
  <td width="50%" bgcolor="{#corTab#}">
   {* Busca e formata a data e hora atuais do servidor para exibicao *}
    <p align="right"><b>{$smarty.now|date_format:"%d/%m/%Y %H:%M"}</b>
  </td>
 </tr>
 <tr>
  <td width="100%" colspan="2" bgcolor="#FBFBFB"><br>
   
  {section name=i loop=$titulos}

   {* busca e formata a data e hora da noticia para exibicao *}
  <p>
  <b><u>{$titulos[i]}</u></b> <i>({$datas[i]|date_format:"%d/%m/%Y %H:%M"})</i>
  <br>
  {$textos[i]|truncate}
  {if $textos[i]|count_characters > 80}
   <br><a href="javascript:void(0);" onclick="window.document.frm1.mod.value='noticia'; window.document.frm1.id.value='{$ids[i]}'; window.document.frm1.ac.value='show'; window.document.frm1.submit();">Leia mais...</a>
  {/if}
  </p>
  {/section}


o erro ocorre nesse arquivo, mostra_noticias.tpl:
Code:

{config_load file="index.conf" section="Margens"}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>{$titulo}</title>
</head>
<body bgcolor="{#corFundo#}" topmargin="{#margemSuperior#}" leftmargin="{#margemEsquerda#}">
<table border=0 width=600px align=center>
 <tr>
  <td>
  <font face="{#fonteFace#}" size="5">ID[{$id}] {$titulo}
  {* Busca e formata a data e hora da noticia para exibicao *}
  <i>{$data|date_format:"&nbsp;postado Data: %d/%m/%Y Hora: %H:%M"}</i>
  </font>
  </td>
 </tr>
 <tr>
  <td>
  {$texto} 
  <p align=right>
   <a href="index.php">Voltar</a>
  </p>
  </td>
 </tr>
 <tr>
  <td align=center>
  <i>{$smarty.server.SERVER_NAME}</i>
  </td>
 </tr>
</table>
</body>
</html>

[/code]
Back to top
View user's profile Send private message
trevieri
Smarty n00b


Joined: 26 Apr 2007
Posts: 4

PostPosted: Thu Nov 10, 2011 7:41 pm    Post subject: Reply with quote

resolvido, problema era no $num_lin
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Portuguese All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP