谁能解释下为什么会发生这种情况……
时间:2011-09-16
来源:互联网
Fatal error: Call to a member function mysql_getdata() on a non-object in C:\wamp\www\www\left.php on line 21
PHP code
<?php /********************** global.php **********************/ session_start(); include_once('./configs/config.php'); include_once('./common/smarty/Smarty.class.php'); include_once('./common/mysql.class.php'); // include_once("./conn.php"); include_once("./action.php"); include("./common/fckeditor/fckeditor.asp"); $db = new action(); $db->mysql_conn(); $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]; $smarty->assign("t_dir",$smarty_template_dir); include_once("./head.php"); ?>
PHP code
<?php /********************** left.php <li>目录一 <ul> <li>目录1-1</li> <li>目录1-2</li> </ul> </li> **********************/ include_once("global.php"); get_cata(); $smarty->assign("title",$name); $smarty->display("left.html"); function get_cata($level=0,$Pid=0) { $result=$db->mysql_getdata("mp_cata","id=$Pid"); while($row=@mysql_fetch_assoc($result)) { echo $row['Cataname']; } } ?>
作者: kkkgho 发布时间: 2011-09-16
作者: xuzuning 发布时间: 2011-09-16
global $db = new action();
这样会出错
作者: kkkgho 发布时间: 2011-09-16
作者: dream1206 发布时间: 2011-09-16
$db = new action();
$db->mysql_conn();
改成这样以后声明变量处没有报错了,但是还是提示调用了一个不存在的函数,在不存在的对象下。
Fatal error: Call to a member function mysql_getdata() on a non-object in C:\wamp\www\www\left.php on line 21
作者: kkkgho 发布时间: 2011-09-16
作者: liangjiankang 发布时间: 2011-09-16
{
global $db;
$result=$db->mysql_getdata("mp_cata","id=$Pid");
while($row=@mysql_fetch_assoc($result))
{
echo $row['Cataname'];
}
}
改成这样以后就好了……但是为什么感觉不太规范呢?
作者: kkkgho 发布时间: 2011-09-16
PHP code
function get_cata($level=0,$Pid=0) { global $db; $result=$db->mysql_getdata("mp_cata","id=$Pid"); while($row=@mysql_fetch_assoc($result)) { echo $row['Cataname']; } }
作者: dream1206 发布时间: 2011-09-16
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28