hi guys, i'm having an SQL Error in my CMS, somebody please have a look

i get this error:

"Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files (x86)\VertrigoServ\www\portal\estrutura\publicidades\exibe.php on line 73"

my code:

<?

$variables=(strtolower($_SERVER['REQUEST_METHOD'])== 'GET') ? $_GET : $_POST;

foreach ($variables as $k=> $v)

$$k=$v;



$palavra = "Publicidade";

$tabela = "publicidades";



$file = "$tabela";



// INICIO DA ACAO DE EXIBIR BANNER

if($acao == "exibe"){



//$pga = $_GET[pg];



    if($formato=="172"){ $largura = "170"; $altura = "72";}

    if($formato=="572"){ $largura = "572"; $altura = "92";}

    if($formato=="80"){ $largura = "80"; $altura = "65";}

    if($formato=="81"){ $largura = "80"; $altura = "65";}

    if($formato=="200"){ $largura = "200"; $altura = "200";}

    if($formato=="650"){ $largura = "650"; $altura = "75";}

    if($formato=="140"){ $largura = "140"; $altura = "200";}

    if($formato=="171"){ $largura = "171"; $altura = "250";}



    if(!empty($posicao)){

    $posicao = "AND posicao='$posicao'";

    } 



        if(!empty($pga)){

        $paginaq = "AND pagina='$pga'";

        }



//if($acao == "exibe" AND $formato=="1024"){ include "../../config.php";}



$busca = "SELECT * FROM $tabela WHERE status='S' AND formato='$formato' $paginaq $posicao GROUP by rand() LIMIT 1";

$query = mysql_query($busca);

$total = mysql_num_rows($query);



    if($total == 0){

    echo "<img width='$largura' height='$altura' src='".$usite."images/layout/sem_banner".$largura.".gif' border='0'>";

    } else {

        $dados = mysql_fetch_array($query);

        // COMEÇA CODIGO PRA EXIBIR BANNERS TIPO IMAGEM

        if($dados[tipo] == 'imagem'){

            if(!empty($dados[url])){

            echo "<a href='$dados[link]' target='_blank'><img width='$largura' height='$altura' name='imagem1' src='$dados[url]' border='0'></a>";

            } else {

            echo "<a href='$dados[link]' target='_blank'><img width='$largura' height='$altura' name='imagem1' src='".$usite."images/$tabela/$dados[imagem]' border='0'></a>";

            }

        }



        // COMEÇA CODIGO PRA EXIBIR BANNERS TIPO FLASH

        if($dados[tipo] == 'flash'){

            if(!empty($dados[url])){

            echo "<embed src='$dados[url]' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='$largura' height='$altura'></embed>";

            } else {

            echo "<script>exibeFash('".$usite."images/$tabela/$dados[imagem]', $largura, $altura, 1, 1);</SCRIPT>";

            //echo "<embed src='".$usite."images/$tabela/$dados[imagem]' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='$largura' height='$altura'></embed>";

            }

        }



        // COMEÇA CODIGO PRA EXIBIR BANNERS TIPO HTML

        if($dados[tipo] == 'html'){

        echo $dados[html];

        }   



    }

}

// FIM DA ACAO DE EXIBIR BANNER

?>

Thanks

The query on line 71 probably didn't work. Your code doesn't have a Connect so I take it that was done previously but not shown. I suggest that you echo $busca at line 70. I find what you're doing with $posicao confusing and probably won't work the way you expected it to.

solved thanks....it was just MySQL cache

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.