slider in js problems to read the BLOB images

0

I have a code that works perfectly on another website, but in this one that is a renewal it is giving me problems, I attach the error and the code:

  

(!) SCREAM: Error suppression ignored for   (!) Warning: mysql_num_rows () expects parameter 1 to be resource, boolean given in C: \ wamp \ www \ claromeconet.com \ components \ imagenes.php on line 3

Code:

<?php
$image_query = mysql_query("SELECT 'id','hash' FROM 'img_alq' WHERE 'estado'='1' AND 'idalq'='{$prop['id']}' ORDER BY 'orden' ASC;");
$images = mysql_num_rows($image_query);
?>

<div class="imagen-propiedad">
    <div class="slider">
        <?php if($images==0){
            echo '<img src="/images/BannerProximamente200x150.png" />';
        }
        while($row_image=mysql_fetch_assoc($image_query)){
            echo "<img src=\"/images/200x150.php?para=alq&id={$row_image['id']}&hash={$row_image['hash']}\" />";
        }
        mysql_free_result($image_query)?>
    </div>
</div>

<?php if($images>1){ ?>
    <script type="text/javascript">
        $('#prop_<?php echo $prop['id'] ?> .slider').slidesjs({
            width:200,
            height:150,
            navigation:{active:false},
            play:{interval:5000,auto:true},
            fade:{speed:300}
        });
    </script>
<?php } ?>

Code 200x150.php:

<?php
include('../../componentes/var.php');
set_time_limit(20);
if(isset($_GET['id']) and preg_match($expr_idusuario,$_GET['id'])){
    if(isset($_GET['hash']) and preg_match($expr_hash_reg,$_GET['hash'])){
        if(isset($_GET['para']) and preg_match("/^(alq|user|hotel|album|serv){1}$/",$_GET['para'])){
            $query=mysql_query("SELECT '200x150', 'hash', 'estado' FROM 'img_{$_GET['para']}' WHERE 'id'='{$_GET['id']}' LIMIT 1;");
            if(mysql_num_rows($query)==1){
                $img=mysql_fetch_assoc($query);
                if($img['hash']==$_GET['hash']){
                    if($img['estado']){
                        $expires = 60*60*8;
                        header("Pragma: public");
                        header("Cache-Control: maxage=".$expires);
                        header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
                        header("Content-type: image/png");
                        echo $img['200x150'];
                    }else echo 'Deshabilitada.';
                }else echo 'Hash incompatible.';
            }else echo 'Sin resultados.';
        }else echo 'Para erroneo.';
    }else echo 'Hash erroneo.';
}else echo 'ID erroneo.';
?>

Basically what this code does is read in a table "img_alq" some images in BLOB format "200x150", then build a slider with the small js below.

    
asked by Ricardo Pastuszek 30.05.2017 в 22:39
source

1 answer

0

The error is clearly on line 3 of your imagenes.php file and it says that the mysql_num_rows function expects a resource as the first parameter and received a boolean value. Basically you lack code to verify that the query has been executed successfully. The result of the function mysql_query can be a resource or a boolean with value false if an error occurred in the execution of the query. In the event that the result is false what is conducive is that you call the function mysql_error to obtain the error information.

However, beyond this problem, the code still uses the mysql_* functions, which are already considered obsolete, besides being vulnerable to SQL code injections. So I recommend you modify the code to use PDO or mysqli_* functions and also use commands prepared with parameters instead of creating an SQL command string dynamically as the current code does.

    
answered by 30.05.2017 / 23:10
source