Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] Fatal error: Uncaught -> Probando Smarty

Estas en el tema de Fatal error: Uncaught -> Probando Smarty en el foro de PHP en Foros del Web. Código: Fatal error: Uncaught --> Smarty Compiler: Syntax error in template ".\templates\index.html" on line 9 "{foreach name=categorias form=$categorias item=categoria}" missing "from" attribute <-- thrown in ...
  #1 (permalink)  
Antiguo 19/04/2014, 20:04
 
Fecha de Ingreso: enero-2008
Mensajes: 580
Antigüedad: 16 años, 3 meses
Puntos: 9
Fatal error: Uncaught -> Probando Smarty

Código:
Fatal error: Uncaught --> Smarty Compiler: Syntax error in template ".\templates\index.html" on line 9 "{foreach name=categorias form=$categorias item=categoria}" missing "from" attribute <-- thrown in C:\xampp\htdocs\smarty\libs\sysplugins\smarty_internal_templatecompilerbase.php on line 9
Código PHP:
<?php
    
include('libs/Smarty.class.php');
    
$categorias[0]["url"]="noticias.php";
    
$categorias[0]["categoria"]="Noticias";
    
$categorias[1]["url"]="deportes.php";
    
$categorias[1]["categoria"]="Deportes";
    
$titulo="Mi Web";
    
$html=new Smarty();
    
$html->assign("categorias"$categorias);
    
$html->assign("titulo"$titulo);
    
$html->display("index.html");
?>
Código HTML:
<!doctype html>
<html lang="es">
<head>
	<meta charset="UTF-8">
	<title>{$titulo}</title>
</head>
<body>
	<h1>{$titulo}</h1>
	{foreach name=categorias form=$categorias item=categoria}
		<a href="{$categoria.url}" title="{$categoria.categoria}">{$categoria.categoria}</a>
	{\foreach}
</body>
</html> 
  #2 (permalink)  
Antiguo 19/04/2014, 20:35
 
Fecha de Ingreso: enero-2008
Mensajes: 580
Antigüedad: 16 años, 3 meses
Puntos: 9
Respuesta: Fatal error: Uncaught -> Probando Smarty

He corregido un fallo renombrando "FORM" por "FROM"

Código:
Fatal error: Uncaught --> Smarty Compiler: Syntax error in template ".\templates\index.html" on line 17 "{\foreach}" - Unexpected "\" <-- thrown in C:\xampp\htdocs\smarty\libs\sysplugins\smarty_internal_templatecompilerbase.php on line 17
Este fallo lo arreglé cambiando "{\foreach}" por "{/foreach}"

Etiquetas: fatal, html, smarty
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:01.