lpxxfaintxx Posted June 17, 2006 Share Posted June 17, 2006 Hi,I tried doing this: [code]$sql = "SELECT * FROM `tutorials` ORDER BY `id` DESC LIMIT 5 WHERE `activation` = 1";[/code]but it didn't work. Is there any alternatives to this?... the "activation=1" part is a very important part, as well as the DESC LIMIT 5. (It is basically saying, select the latest 5 from tutorials, where it is activated.)Help would be appreciated. :) Quote Link to comment Share on other sites More sharing options...
AndyB Posted June 17, 2006 Share Posted June 17, 2006 Just a matter of precedence:[code]$sql = "SELECT * FROM `tutorials' WHERE `activation` = 1 ORDER BY `id` DESC LIMIT 5";[/code] Quote Link to comment Share on other sites More sharing options...
lpxxfaintxx Posted June 17, 2006 Author Share Posted June 17, 2006 Err.. I got an error..[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/informed/public_html/projects/tuts/index.php on line 114[/quote][code]$sql = "SELECT * FROM `tutorials' WHERE `activation` = '1' ORDER BY `id` DESC LIMIT 5";$result=mysql_query($sql);(line 114)while($rows=mysql_fetch_array($result)){ [/code] Quote Link to comment Share on other sites More sharing options...
AndyB Posted June 17, 2006 Share Posted June 17, 2006 My mistake. Stupid backticks .... ` and ' not the same.Use this instead:[code]$sql = "SELECT * FROM tutorials WHERE activation = '1' ORDER BY id DESC LIMIT 5";$result=mysql_query($sql) or die("Error: mysql_error(). " with query ". $sql); // let's see what went wrong[/code]At least you'll be able to see the exact query used - that should help you find any problems if they still exist. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.