Bopo Posted April 24, 2009 Share Posted April 24, 2009 Hi Basically I keep getting the following error, I definitely know the query is causing the error due to testing: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Below is the query: <?php $sql = "SELECT * FROM blogposts WHERE date >= '$firstdate' AND date <= '$seconddate' ORDER BY id DESC LIMIT '$minus', '$storemultiply'";?> The part that is giving me an error is: ORDER BY id DESC LIMIT '$minus', '$storemultiply' both variables store a number. Help appreciated. Link to comment https://forums.phpfreaks.com/topic/155495-solved-mysql-query-help/ Share on other sites More sharing options...
revraz Posted April 24, 2009 Share Posted April 24, 2009 Echo $sql and post it. Post the exact error. Link to comment https://forums.phpfreaks.com/topic/155495-solved-mysql-query-help/#findComment-818208 Share on other sites More sharing options...
jackpf Posted April 24, 2009 Share Posted April 24, 2009 Put or die(mysql_error()); after the query. Link to comment https://forums.phpfreaks.com/topic/155495-solved-mysql-query-help/#findComment-818211 Share on other sites More sharing options...
Bopo Posted April 24, 2009 Author Share Posted April 24, 2009 Thanks for the suggestions, it seems that putting single quotes around the $minus and $storemultiply variable were causing it. Link to comment https://forums.phpfreaks.com/topic/155495-solved-mysql-query-help/#findComment-818223 Share on other sites More sharing options...
jackpf Posted April 24, 2009 Share Posted April 24, 2009 You would've found it ages ago if you used the mysql_error() function Link to comment https://forums.phpfreaks.com/topic/155495-solved-mysql-query-help/#findComment-818271 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.