Im not sure how to fix this problem i get the mesg: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/a326878750/public_html/tree/database.php on line 255 here is a piece of the code any help plz? mysql_query("UPDATE videoer SET video_views=$views WHERE video_id=$id"); } PHP: function video_alle($order) { if(!isset($_GET['side'])) { $lala2 = "0"; } else { $tal1 = $_GET['side']; $tal2 = $tal1 * 16; $tal3 = $tal2 - 16; $lala2 = $tal3; } $query = mysql_query("SELECT * FROM videoer ORDER BY $order DESC LIMIT $lala2, 16"); while($row = mysql_fetch_assoc($query)) { if($row['video_type'] == "youtube") { echo ' <li> <div class="vediodiv"> '; if($row['video_views'] >= "15000") { echo '<img style="position: absolute;" src="images/icon_pop_da.png" />'; } if($row['video_id'] >= "2222" && $row['video_views'] <= "4999") { echo '<img style="position: absolute;" src="images/icon_ny_da.png" />'; } echo ' <a href="video.php?id=' . $row['video_id'] . '"> <img width="147" height="99" src="http://img.youtube.com/vi/' . $row['video_url'] . '/0.jpg" </a> </div> <div class="clear"></div> <p class="vid-titel"> <a class="colr2" href="video.php?id=' . $row['video_id'] . '">' . $row['video_titel'] . ' </a> </p> <p class="viewcounts">' . number_format($row['video_views']) . ' views</p> <p class="by" >Posted byaf: <a href="#" class="undrlne">admin</a></p> </li> '; } if($row['video_type'] == "goviral") { echo ' <li> <div class="vediodiv"> '; if($row['video_views'] >= "15000") { echo '<img style="position: absolute;" src="images/icon_pop_da.png" />'; } if($row['video_id'] >= "2222" && $row['video_views'] <= "4999") { echo '<img style="position: absolute;" src="images/icon_ny_da.png" />'; } echo ' <a href="video.php?id=' . $row['video_id'] . '"><img src="http://pinoyspinays.com/reklamer/' . $row['video_tumb'] . '" alt="" /> </a> </div> <div class="clear"></div> <p class="vid-titel"> <a class="colr2" href="video.php?id=' . $row['video_id'] . '">' . $row['video_titel'] . ' </a> </p> <p class="viewcounts">' . number_format($row['video_views']) . ' views</p> <p class="by" >Posted byaf: <a href="#" class="undrlne">admin</a></p> </li> '; } } } PHP:
The first thing to do is to change this $tal1 = $_GET['side']; $tal2 = $tal1 * 16; $tal3 = $tal2 - 16; $lala2 = $tal3; } $query = mysql_query("SELECT * FROM videoer ORDER BY $order DESC LIMIT $lala2, 16"); PHP: to this $tal1 = intval($_GET['side']); $tal2 = $tal1 * 16; $tal3 = max($tal2 - 16,0); //what if 'side' is missing or zero? $lala2 = $tal3; } $sql = "SELECT * FROM `videoer` ORDER BY {$order} DESC LIMIT {$lala2}, 16"; echo "<hr>{$sql}</hr>"; $query = mysql_query($sql) or die("Bad SQL: {$sql}<br>".mysql_error()); PHP: Now, grab the sql that gets echo'd out and look at. Any obvious problems? Yes - fix them; No - copy the sql into phpMyAdmin, SqlYog, Toad or whatever you use to manage the database and run the query. You'll get a better error message from that if the query is at fault.