x_man 发表于 2006-11-10 21:46

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

网站根目录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.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.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.NewsID}>"><{NewsTitle}></a>
<{/section}></td>
</tr>
</table>
</body>
</html>

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

后来重装apache服务器后,调试出错:
Fatal error: Smarty error: : syntax error: unrecognized tag: News_CH.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 编辑 ]

iptton 发表于 2006-11-11 00:43

没用过SMARTY....

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

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

hjack 发表于 2006-11-12 16:33

nrecognized tag: News_CH.NewsID

标签写错了?!

管理员2号 发表于 2006-11-13 15:23

本帖最后由 管理员2号 于 2012-7-14 12:28 编辑

顶楼主~~~~~~~~~~~~~~~~~~~~~·

x_man 发表于 2006-11-14 14:44

原帖由 管理员2号 于 2006-11-13 15:23 发表
楼主也是学php和smarty啊?同志同志,呵呵,有空加我qq283673936共商大计,呵呵
好的。。

x_man 发表于 2006-11-14 14:51

原帖由 hjack 于 2006-11-12 16:33 发表
nrecognized tag: News_CH.NewsID

标签写错了?!
谢了!!差了个$.....
页: [1]
查看完整版本: smarty加载出错,求php高手指教