检查你的模板文件index.tpl是否在./templates/这个目录下,并且是否有对此目录的操作权限。

解决方案 »

  1.   

    我昨天也碰到这个问题,非常郁闷,花费了不少时间,觉得没写错,xp下也不存在权限问题。
    总是提示这个错误:Smarty error: unable to read resource: "result.html",
    原来是因为有2个参数没设置:
    $s->compile_check = true;
    $s->debugging = false;
      

  2.   

    我也碰到这样的问题
    看了楼上几位的回答,有几个提问啊
    1.怎么查看权限啊,我觉得这个权限应该没什么问题。因为在其他范例中能得到预期结果
    2.更新下缓存是指清空cache中的文件吗
    3.$s->compile_check = true; $s->debugging = false;这两个参数在哪里设置呢
      

  3.   

    你的路径名有问题,我也遇到跟你一摸一样的问题。把下面的这段代码:
    require_once   ( "../comm/Smarty.class.php "); $smarty   =   new   Smarty(); 
    $smarty-> template_dir   =   './templates/ '; 
    $smarty-> compile_dir   =   './templates_c/ '; 
    $smarty-> config_dir   =   './configs/ '; 
    $smarty-> cache_dir   =   './cache/ '; 改写成:
    //这里:E:/AppServ/www/  是我的控制台路径,就是在http上输入localhost之后出现的位置。
    define('BASE_PATH', 'E:/AppServ/www/');
    //这里:Smarty/是 我的Smarty的安装位置,也就是
    define(‘SMARTY_PATH’,‘Smarty/’);//这里是Smarty.class.php的路径:
    //合起来也就是:E:/AppServ/www/Smarty/Smarty.class.php
    require BASE_PATH.SMARTY_PATH.‘Smarty.class.php‘;
    $smarty=new Smarty();//下面的路径跟上面的差不多:
    $smarty->template_dir=BASE_PATH.SMARTY_PATH.‘templates/’;
    $smarty->complie_dir=BASE_PATH.SMARTY_PATH.’templates_c/‘;
    $smarty->config_dir=BASE_PATH.SMARTY_PATH.‘configs/’;
    $smarty->cache_dir=BASE_PATH.SMARTY_PATH.’cache/‘;总之你的路径一定要设置对了~就行~~