工大后院

 找回密码
 加入后院

扫一扫,访问微社区

QQ登录

只需一步,快速开始

搜索
查看: 2332|回复: 5

smarty加载出错,求php高手指教

[复制链接]
发表于 2006-11-10 21:46 | 显示全部楼层 |阅读模式
网站根目录smarty
|--smarty
  |--class
     |--Smarty.class.php
     |--Config_File.class.php
     |--Smarty_Compiler.class.php
     |--plugins
     |--internals
  |--configs
  |--includes
  |--templates
    |--index.tpl
  |--templates
  |--cache
  |--index.php
  |--news.php
  |--main.php

index.php

<?php

//新闻显示主页
require "main.php";
//define("NUM",5);

$db = mysql_connect("localhost","dudu","128307111");
mysql_select_db("news",$db) or die;

//国内新闻部分
$strQuery = "SELECT vcNewsTitle , iNewsID FROM mz_news_ch ORDER BY iNewsID DESC";
$result = mysql_query($strQuery) or die;
$i=NUM;

while(($rows = mysql_fetch_array($result)) && $i > 0)
{
        $array[] = array("NewsID" => substr($rows["iNewsID"],0,40),"NewsTitle" => substr($rows["vcNewsTitle"],0,40));
        $i--;
}

$smarty->assign("News_CH",$array);
unset($array);
mysql_free_result();


//国际新闻部分
$strQuery = "SELECT vcNewsTitle , iNewsID FROM mz_news_in ORDER BY iNewsID DESC";
$result = mysql_query($strQuery);
$i=NUM;

while(($rows = mysql_fetch_array($result)) && $i > 0)
{
        $array[] = array("NewsID" => substr($rows["iNewsID"],0,40),"NewsTitle" => substr($rows["vcNewsTitle"],0,40));
        $i--;
}

$smarty->assign("News_IN",$array);
unset($array);
mysql_free_result();

//娱乐新闻部分$strQuery = "SELECT vcNewsTitle , iNewsID FROM mz_news_mu ORDER BY iNewsID DESC";
$result = mysql_query($strQuery);
$i=NUM;

while(($rows = mysql_fetch_array($result)) && $i > 0)
{
        $array[] = array("NewsID" => substr($rows["iNewsID"],0,40),"NewsTitle" => substr($rows["vcNewsTitle"],0,40));
        $i--;
}

$smarty->assign("News_MU",$array);
unset($array);
mysql_free_result();

mysql_close($db);

$smarty->display("index.html");

?>

main.php

<?php
require('class/Smarty.class.php');

define('__SITE_ROOT', 'd:/httproot/smarty');

$smarty = new Smarty();

$smarty->templates_dir = __SITE_ROOT."/templates/";
$smarty->compile_dir = __SITE_ROOT."/templates_c/";
$smarty->config_dir = __SITE_ROOT . "/configs/";
$smarty->cache_dir = __SITE_ROOT."/cache/";

$smarty->cache_lifetime = 60*60*24;
$smarty->caching = ture;

$smarty->left_delimiter = "<{";
$smarty->right_delimiter = "}>";
?>

模版文件 index.tpl
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新闻主页</title>
</head>
<body>
<table width="100%">
<tr>
<td valign="top" width="295" height="115" bgcolor="#b9e9ff">
<{section name=loop loop=$News_CH}>
<li><a href="news.php?type=1&id=<{News_CH[loop].NewsID}>"><{NewsTitle}></a>
<{/section}>
</td>
</tr>
</table>
<table width="100%">
<tr>
<td valign="top" width="295" height="115" bgcolor="#b9e9ff">
<{section name=loop loop=$News_IN}>
<li><a href="news.php?type=2&id=<{News_IN[loop].NewsID}>"><{NewsTitle}></a>
<{/section}>

</td>
</tr>
</table>
<table width="100%">
<tr>
<td valign="top" width="295" height="115" bgcolor="#b9e9ff">
<{section name=loop loop=$News_MU}>
<li><a href="news.php?type=3&id=<{News_MU[loop].NewsID}>"><{NewsTitle}></a>
<{/section}>
</td>
</tr>
</table>
</body>
</html>

求救:无法调试出页面,浏览器空白,甚至把index.php文件故意改成错误也不能提示,还是空白。。。。急……

后来重装apache服务器后,调试出错:
Fatal error: Smarty error: [in index.html line 11]: syntax error: unrecognized tag: News_CH[loop].NewsID (Smarty_Compiler.class.php, line 439) in D:\httproot\smarty\class\Smarty.class.php on line 1095

顺便问一下,mysql4.0.*是不是不支持mysql_free_result()
求救…………

[ 本帖最后由 x_man 于 2006-11-10 21:50 编辑 ]
发表于 2006-11-11 00:43 | 显示全部楼层
没用过SMARTY....

无法调试出页面,浏览器空白,甚至把index.php文件故意改成错误也不能提示,还是空白。。。。

感觉这个应该是cache的问题
随意加个参数应该可以解决比如  index.php?abd
回复

使用道具 举报

发表于 2006-11-12 16:33 | 显示全部楼层
nrecognized tag: News_CH[loop].NewsID

标签写错了?!
回复

使用道具 举报

发表于 2006-11-13 15:23 | 显示全部楼层
本帖最后由 管理员2号 于 2012-7-14 12:28 编辑

顶楼主~~~~~~~~~~~~~~~~~~~~~·
回复

使用道具 举报

 楼主| 发表于 2006-11-14 14:44 | 显示全部楼层
原帖由 管理员2号 于 2006-11-13 15:23 发表
楼主也是学php和smarty啊?同志同志,呵呵,有空加我qq283673936共商大计,呵呵

好的。。
回复

使用道具 举报

 楼主| 发表于 2006-11-14 14:51 | 显示全部楼层
原帖由 hjack 于 2006-11-12 16:33 发表
nrecognized tag: News_CH.NewsID

标签写错了?!

谢了!!差了个$.....
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入后院

本版积分规则

QQ|Archiver|手机版|小黑屋|广告业务Q|工大后院 ( 粤ICP备10013660号 )

GMT+8, 2025-5-15 23:55

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表