dounai7148 2014-02-07 06:16
浏览 31
已采纳

从mysql表中列出数据[重复]

I am trying to list data from a mysql,

but I get the error:

"Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/cassiano/public_html/myradio.net.br/events.php on line 114"

I can not paste the code here, always goes wrong, then please see the notepad code

Thanks

</div>
  • 写回答

1条回答 默认 最新

  • drfif48428 2014-02-07 06:23
    关注

    you used given statement in your code

      $total_playlist = mysql_num_rows(mysql_query("SELECT * FROM agenda_playlist where codigo_stm = '".$dados_stm["codigo"]."' ORDER by login"));
    

    here

     mysql_query("SELECT * FROM agenda_playlist where codigo_stm = '".$dados_stm["codigo"]."' ORDER by login")
    

    will output the empty result you need to modify it

    Try This

    $total_playlist = 0;
    $res_count = mysql_query("SELECT count(*) as cnt FROM agenda_playlist where codigo_stm = '".$dados_stm["codigo"]."' ORDER by login");
    if($row_count = mysql_fetch_assoc($res_count))
    {
       $total_playlist = $row_count['cnt'];
    }
    

    instead of

    $total_playlist = mysql_num_rows(mysql_query("SELECT * FROM agenda_playlist where codigo_stm = '".$dados_stm["codigo"]."' ORDER by login"));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样