-1

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

user3086014
  • 3,933
  • 5
  • 26
  • 52
Cassiano José
  • 139
  • 1
  • 6
  • Use this to debug whats wrong, using this you may debug the exact issue whether the query fails, try this $result = mysql_query($sql) or die('Invalid query: ' .mysql_error()); – Sunil Kumar Feb 07 '14 at 06:26
  • Don't use `mysql_*` ever. It has large security issues and has been replaced with `mysqli` or `PDO`. – Benedict Lewis Feb 07 '14 at 06:37

1 Answers1

1

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"));
Satish Sharma
  • 9,475
  • 6
  • 27
  • 51
  • Use this to debug whats wrong, using this you may debug the exact issue whether the query fails, try this $result = mysql_query($sql) or die('Invalid query: ' .mysql_error()); – Sunil Kumar Feb 07 '14 at 06:24