使用PHP直接用echo打印数据库里查询出来的内容的时候,出来的内容全部都是正常的,但结合Smarty后,页面里出现的内容就成乱码了,请问下各位PHP高手,如何解决这样问题。
本人刚学PHP不久,还请各位给予帮助。
数据库设计:
create database demo character set utf8;
create table tb_notice(id int primary key auto_increment,title varchar(64),memo varchar(200),addtime date);
insert table tb_notice(title,memo,adddtime) values('测试中文','测试中文',curdate());require_once(root.'/includes/db_class.php');
require_once(root.'/includes/config.php');
require_once(root.'/includes/function.php');$result = $db->query('select * from tb_notices'); header('Content-Type:text/html;charset=gbk');
$smarty->assign("pageTitle","新闻内容");
$smarty->assign("newsCount",$db->num_rows($result));
$smarty->assign("newsList",$db->fetch_array($result));$smarty->display("default.html"); //显示模板页面循环为:<{section name=item loop=$newsList}>
<{$newsList[item].title}>
<{/section}>还请各位帮助。谢谢
本人刚学PHP不久,还请各位给予帮助。
数据库设计:
create database demo character set utf8;
create table tb_notice(id int primary key auto_increment,title varchar(64),memo varchar(200),addtime date);
insert table tb_notice(title,memo,adddtime) values('测试中文','测试中文',curdate());require_once(root.'/includes/db_class.php');
require_once(root.'/includes/config.php');
require_once(root.'/includes/function.php');$result = $db->query('select * from tb_notices'); header('Content-Type:text/html;charset=gbk');
$smarty->assign("pageTitle","新闻内容");
$smarty->assign("newsCount",$db->num_rows($result));
$smarty->assign("newsList",$db->fetch_array($result));$smarty->display("default.html"); //显示模板页面循环为:<{section name=item loop=$newsList}>
<{$newsList[item].title}>
<{/section}>还请各位帮助。谢谢
解决方案 »
- PHP 菜鸟问个问题
- ajax传递session值问题
- 如何最优化传递数据库对象?
- apache在配置php时无法启动了 急!
- 想实现这样一个缓存功能,请大家帮忙.
- Notice: Undefined index: ACTION in c:\accounts\bayrealt\wwwroot\hr\appraisal\signin.php on line 9
- php的wordpress运行有点慢
- 如何显示php生成的WBMP图像
- 我郁闷了呀:( 一个正则表达式的问题 PHP,preg_match
- 小弟初学,问个简单问题
- eclipse forphp配置了xdebub调试,却不能调试html文件,咱调试html文件的?
- session的问题,大侠进来看看
你的错误再: header('Content-Type:text/html;charset=utf-8');这里!!呵呵!!最近我对是smarty研究还是挺深的了!
header('Content-Type:text/html;charset=utf-8');