从mysql表中列出数据

时间:2014-02-07 06:16:21

标签: javascript php html mysql css

我正在尝试列出来自mysql的数据

但我收到错误

"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"

我无法在此处粘贴代码,总是出错,请参阅notepad code

谢谢

1 个答案:

答案 0 :(得分:1)

您在代码中使用了给定语句

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

这里

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

将输出您需要修改的空结果

试一下

$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'];
}

而不是

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