dpa0760 2012-05-03 23:06
浏览 50
已采纳

mysql_fetch_object()的错误处理:提供的参数不是有效的MySQL结果

My question is how to remove the error, message saying

mysql_fetch_object(): supplied argument is not a valid MySQL result.

I need to throw/catch this error, but not sure how to do this.

When this function has a result to return, it works properly.

It is just that when when the result returns null, it says supplied argument is not a valid mysql result.

So how do I remove this error, so when it doesn't have anything to return, instead of displaying mysql_fetch_object(): supplied argument is not a valid MySQL result, it shows the user what I want.

$posts = show_allgroupsposts1($myusers,5);
if (count($posts)){
do a bunch of stuff.
}else{
nothing to display.
}
?>

currently, it returns:

mysql_fetch_object(): supplied argument is not a valid MySQL result
nothing to display.
  • 写回答

2条回答 默认 最新

  • duanjiebian6712 2012-05-03 23:10
    关注

    You should check wither the result variable is false.

    if($result)
        mysql_fetch_object();
    else
        ...do nothing
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站