PHP - Smarty 错误
使用Wamp+dreamwever错误信息:php文件:“$query=$db->query("SELECT*FROM`p_config`");$row=$db->fet...
使用Wamp + dreamwever
错误信息:
php文件:
“
$query=$db->query("SELECT * FROM `p_config`");
$row=$db->fetch_array($query);
echo $row[name]."=".$row[values]; //测试数据库是否连接成功
$smarty->assign("row",$row[name]);
$smarty->display("index.html");
”
html文件:
“
{$row}
”
“
Fatal error: Uncaught exception 'Exception' with message 'Error: lexing failed because a rule matchedan empty string. Input "$row}... state SMARTY' in D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal_templatelexer.php:458 Stack trace: #0 D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal_templatelexer.php(101): Smarty_Internal_Templatelexer->yylex2() #1 D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal_smartytemplatecompiler.php(49): Smarty_Internal_Templatelexer->yylex() #2 D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal_templatecompilerbase.php(82): Smarty_Internal_SmartyTemplateCompiler->doCompile('<!DOCTYPE html ...') #3 D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal_template.php(260): Smarty_Internal_TemplateCompilerBase->compileTemplate(Object(Smarty_Internal_Template)) #4 D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal_template.php(422): Smarty_Internal_Template->compileTemplateSource() #5 D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal in D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal_templatelexer.php on line 458
”
连接数据库正常,请各位大大帮我看看哈..
*****************global.php**********************
include_once ('./configs/config.php');
include_once ('./common/smarty/Smarty.class.php');
include_once ('./common/mysql.class.php');
include_once ('./common/action.class.php');
$db = new action($mydbhost,$mydbuser,$mydbpw,$mydbname,ALL_PS,$mydbcharset);
//*****smarty**********
$smarty = new smarty();
$smarty->template_dir = $smarty_template_dir;
$smarty->compile_dir = $smarty_compile_dir;
$smarty->config_dir = $smarty_config_dir;
$smarty->cache_dir = $smarty_cache_dir;
$smarty->caching = $smarty_caching;
$smarty->left_delimiter = $smarty_delimiter[0];
$smarty->right_delimiter = $$smarty_delimiter[1];
***************config.php****************
$smarty_template_dir = './templates';
$smarty_compile_dir = './templates_c';
$smarty_config_dir = './configs';
$smarty_cache_dir = './cache';
$smarty_caching = false;
$smarty_delimiter = explode("|","{|}"); 展开
错误信息:
php文件:
“
$query=$db->query("SELECT * FROM `p_config`");
$row=$db->fetch_array($query);
echo $row[name]."=".$row[values]; //测试数据库是否连接成功
$smarty->assign("row",$row[name]);
$smarty->display("index.html");
”
html文件:
“
{$row}
”
“
Fatal error: Uncaught exception 'Exception' with message 'Error: lexing failed because a rule matchedan empty string. Input "$row}... state SMARTY' in D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal_templatelexer.php:458 Stack trace: #0 D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal_templatelexer.php(101): Smarty_Internal_Templatelexer->yylex2() #1 D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal_smartytemplatecompiler.php(49): Smarty_Internal_Templatelexer->yylex() #2 D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal_templatecompilerbase.php(82): Smarty_Internal_SmartyTemplateCompiler->doCompile('<!DOCTYPE html ...') #3 D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal_template.php(260): Smarty_Internal_TemplateCompilerBase->compileTemplate(Object(Smarty_Internal_Template)) #4 D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal_template.php(422): Smarty_Internal_Template->compileTemplateSource() #5 D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal in D:\php_webpage\tec\common\smarty\sysplugins\smarty_internal_templatelexer.php on line 458
”
连接数据库正常,请各位大大帮我看看哈..
*****************global.php**********************
include_once ('./configs/config.php');
include_once ('./common/smarty/Smarty.class.php');
include_once ('./common/mysql.class.php');
include_once ('./common/action.class.php');
$db = new action($mydbhost,$mydbuser,$mydbpw,$mydbname,ALL_PS,$mydbcharset);
//*****smarty**********
$smarty = new smarty();
$smarty->template_dir = $smarty_template_dir;
$smarty->compile_dir = $smarty_compile_dir;
$smarty->config_dir = $smarty_config_dir;
$smarty->cache_dir = $smarty_cache_dir;
$smarty->caching = $smarty_caching;
$smarty->left_delimiter = $smarty_delimiter[0];
$smarty->right_delimiter = $$smarty_delimiter[1];
***************config.php****************
$smarty_template_dir = './templates';
$smarty_compile_dir = './templates_c';
$smarty_config_dir = './configs';
$smarty_cache_dir = './cache';
$smarty_caching = false;
$smarty_delimiter = explode("|","{|}"); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询