Warning: mysql_num_rows () expects parameter 1 to be resource, boolean given in [duplicate]

0

I have a problem with the mysql_num_rows ()

  

"Warning: mysql_num_rows () expects parameter 1 to be resource, boolean   given "

I've been browsing other posts but none could help me. PHP looks like this:

//Sistema de paginação

$sql_select_all = "SELECT id, nome, descricao, 'empresa' as empresa, 'empresa' as tipo  
                FROM tbl_empresa
                WHERE id LIKE '%".$colname_Pesquisa."%' OR nome LIKE '%".$colname_Pesquisa."%' OR descricao LIKE '%".$colname_Pesquisa."%'
                UNION ALL
                SELECT tbl_produto.id, tbl_produto.nome, tbl_produto.descricao, tbl_empresa.nome, 'produto' as tipo 
                FROM tbl_produto 
                JOIN tbl_empresa
                ON tbl_empresa.id = tbl_produto.tbl_empresa_id  
                WHERE tbl_produto.id LIKE '%".$colname_Pesquisa."%' OR tbl_produto.nome LIKE '%".$colname_Pesquisa."%' OR tbl_produto.descricao LIKE '%".$colname_Pesquisa."%'";

$sql_query_all = mysql_query($sql_select_all);

//O problema esta aqui
$total_registros = mysql_num_rows($sql_query_all);

I already checked the select and it is returning the expected value, so much it shows on the page. Realized that $total_registros e $sql_query_all do not return anything to me;

The code is working perfectly on my localhost (PHP 5.3.0), but when I went to the server (PHP 5.3.29) it appeared that error. I do not think there's any difference between those versions that would impact that way.

If anyone can help me, I'll be grateful!

    
asked by anonymous 01.10.2015 / 19:48

2 answers

0

The error was here:

 mysql_query($sql_select_all) or die(mysql_error())

When doing this I was able to observe the error in sql and fix.

Thank you all!

    
05.10.2015 / 14:33
-1

Make the following change:

$ret = mysql_query($sql_select_all);
if(!$ret){
    die("Erro de conexao")
}else{
    $total_registros = mysql_num_rows($sql_query_all);
}
    
01.10.2015 / 20:40
___ ___ erkimt Reading json correctly to generate the data for the chart (Ajax and Morris) ______ qstntxt ___

link

I am not able to return json via ajax, I tried with console.log but it is returning the function itself that I mounted

%pre%

How do I return the json I had ridden before?

All this is to generate the graph, but it is not reading json correctly.

I'm following the tutorial on this site

link

    
______ azszpr99132 ___
%pre%     
___ Force user to run application with privileges