Fatal error: Call to a member function mysql_getdata() on a non-object in C:\wamp\www\www\left.php on line 21<?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
/**********************
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'];
}
}
?>
global $db = new action();
这样会出错
$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
{
global $db;
$result=$db->mysql_getdata("mp_cata","id=$Pid");
while($row=@mysql_fetch_assoc($result))
{
echo $row['Cataname'];
}
}改成这样以后就好了……但是为什么感觉不太规范呢?
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'];
}
}