我把函数发出来给你们看看:
<? //函数:ArticleShow
//功能:视频专区推荐广告。
//参数:$t为文章类型参数
function ArticleShow($t) {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?
require_once('config.inc.php');
$result=$db->query("select * from article where Types=$t limit 10");
while ($rs=$db->getobject($result))
  {
?> 
 <tr>
   <td height="16" align="center"><a href="View.php?aid=<?=$rs->aid?>" target="_blank"><?=$rs->Title?></a></td>
   </tr>
<?
}
?>
</table>
<?
}
////////////////////////////////////////////////////////////////
?>就这样一个简单的函数,其中config.inc.php对数据库的操作封装成类,$db是用new后取得的类对象,这个数据库类是没问题的,在我别的所有数据库操作页面都没问题
楼上的谢谢帮我看看怎么调用时出那样的问题,

解决方案 »

  1.   

    两次参数分别是什么,
    $result=$db->query("select * from article where Types=$t limit 10");
    =>
    $result=$db->query("select * from article where Types='$t' limit 10");
      

  2.   

    你没有new $db  这个对象
    或者在其他地方已经实例化了这个对象,但是你没有引用过来
      

  3.   

    在config.inc.php,我就已经new $db了,所以在这里我是直接引用,
    我想知道Call to a member function on a non-object这句话的意思,
      

  4.   

    你给的错误信息不全
    请指出Require.inc.php 的第 40 行在哪里
      

  5.   

    没有,在对象初始化时名字我还是很注意区分的,$db我只在configl.inc.php这一个文件初始化,而且我在别的地方引用这个对象时也没问题,
    但是我将这个放在上面的函数中再连续调用函数时,比如
    <?
    ArticleShow(1);
    ArticleShow(2);
    ArticleShow(3);
    ?
    时只有ArticleShow(1)能显示出来,后面就出现上面的问题,
      

  6.   

    Fatal error: Call to a member function on a non-object in Require.inc.php on line 40你的四十行是什么东东来着.
      

  7.   

    第40行是
    $result=$db->query("select * from article where Types=$t limit 10");
      

  8.   

    我这个函数是放在Require.inc.php 文件里的
      

  9.   

    'config.inc.php'In this file, in the "getobject" function, you must have unset $db.Change "require_once('config.inc.php');" to "require('config.inc.php');"
      

  10.   

    文件里插入几个print_r($db)就能看出来了,比如在第40行插入一个,看看显示什么.这个错误就是说你的$db不是一个对象.
      

  11.   

    <? //函数:ArticleShow
    //功能:视频专区推荐广告。
    //参数:$t为文章类型参数
    require_once('config.inc.php');//require_once再次调用将返回true,这就是为什么你会报不是对象的原因
    function ArticleShow($t) {
    global $db;
    ?>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <?
    $result=$db->query("select * from article where Types=$t limit 10");
    while ($rs=$db->getobject($result))
      {
    ?> 
     <tr>
       <td height="16" align="center"><a href="View.php?aid=<?=$rs->aid?>" target="_blank"><?=$rs->Title?></a></td>
       </tr>
    <?
    }
    ?>
    </table>
    <?
    }
    ////////////////////////////////////////////////////////////////
    ?>
      

  12.   

    $db 根本就无传进去,我是这样改的function ArticleShow($t,$db)
    {
    print "www.geocharming.com 壶缘茶道 最专业的茶文化爱好者网站";
    }
    引用的时候就ArticleShow($t,$db),这样就可以把$db带进去了我刚刚也遇到这个问题,找资料的时候找到你的问题,现在顺便一起解决了
      

  13.   

    Fatal error: Call to a member function on a non-object in Require.inc.php on line 40
    在Require.inc.php文件的第40行,发生了一个不存在的类,调用自定义函数的操作。 可以这样理解吧!  一般就是没有初始化类!
      

  14.   

    没有初始化类,或者调用类的时候用错了名字, 我有一次是$data写成了$date然后自己没发觉。楼主可能是大小写敏感