1

when I show data from mysql I get this warning:

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/zh004600/www_root/public/text/atomia/find.php on line 821

But I see result. What can I do to not have this warning? line 821 is line with while loop "while ($row1 = mysql_fetch_assoc($result1)) {"

Can anybody help?

    echo '<table class="files" cellspacing="3" cellpadding="3">';

                                    $query = 

'SELECT * FROM files WHERE cz ='.$Podp;
                                $result = mysql_query($query);
                                $resultCount = mysql_num_rows($result) + 3;

                                for ($k=0;$k<$resultCount;$k+=4) {
                                    $j= $k-4;
                                        echo '<tr class="files">';
                                            if ($j == 0) {
                                                $query1 = 'SELECT * FROM files WHERE cz ='.$Podp.' LIMIT 4'; 
                                            } else {
                                                $query1 = 'SELECT * FROM files WHERE cz ='.$Podp.' LIMIT 4 OFFSET '.$j;
                                            }
                                                $result1 = mysql_query($query1);
                                                    while ($row1 = mysql_fetch_assoc($result1)) {
                                                        $nazov = $row1['nazov'];
                                                        $cesta = $row1['cesta'];                            
                                                        echo '<th class="files"><a href="'.$cesta.'" download><img src="img/icons/pdf.png" width="45"></a><br>'.$nazov.'</th>';

                                                    }
                                        echo '</tr>';
                                }
                        echo '</table>';
Stanley01
  • 67
  • 8

1 Answers1

2

Just add this check

if($result1){

like this:

$result1 = mysql_query($query1);
    if($result1){ // <-- THIS CHECK
        while ($row1 = mysql_fetch_assoc($result1)) {
            $nazov = $row1['nazov'];
            $cesta = $row1['cesta'];                            
            echo '<th class="files"><a href="'.$cesta.'" download><img src="img/icons/pdf.png" width="45"></a><br>'.$nazov.'</th>';

        }
    }
Alexander Reznikov
  • 1,254
  • 1
  • 11
  • 23