chriscloyd Posted January 27, 2007 Share Posted January 27, 2007 heres my error[quote]Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/srxstud/public_html/test22/includes/liveprojects.php on line 7[/quote]heres my code[code]<?php$get_num_project = mysql_query("SELECT * FROM projects WHERE status = 'Completed'");$num_project = mysql_num_rows($get_num_project);$maxlimit = rand(1,$num_project);$minlimit = $maxlimit - 5;$project_get = mysql_query("SELECT * FROM projects WHERE status = 'Completed' LIMIT '$minlimit','$maxlimit'");while ($p = mysql_fetch_assoc($project_get)) { echo '<table width="95%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="85%">'.$p['title'].'</td> <td align="center" width="15%"><a href=portfolio.php?project='.$p['id'].'">View</a></td> </tr> </table>';}?>[/code] Link to comment https://forums.phpfreaks.com/topic/35964-solved-a-mysql_fetch-error-using-php/ Share on other sites More sharing options...
Orio Posted January 27, 2007 Share Posted January 27, 2007 It may be that $minlimit is negative and that's why there's an error.Try:[code]$minlimit = (($maxlimit - 5) > 0) ? $maxlimit - 5 : 0;[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/35964-solved-a-mysql_fetch-error-using-php/#findComment-170559 Share on other sites More sharing options...
chriscloyd Posted January 31, 2007 Author Share Posted January 31, 2007 i tried that it didnt work Link to comment https://forums.phpfreaks.com/topic/35964-solved-a-mysql_fetch-error-using-php/#findComment-173348 Share on other sites More sharing options...
Jessica Posted January 31, 2007 Share Posted January 31, 2007 $project_get = mysql_query("SELECT * FROM projects WHERE status = 'Completed' LIMIT '$minlimit','$maxlimit'") OR die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/35964-solved-a-mysql_fetch-error-using-php/#findComment-173349 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.