MDanz Posted April 5, 2010 Share Posted April 5, 2010 i have 2 mysql query. $construct = "SELECT * FROM `Stacks` WHERE $construct AND positive=1 ORDER by posted DESC" or die (mysql_error()); and $construct = "SELECT * FROM `Stacks` WHERE $construct AND positive=0 ORDER by posted DESC" or die (mysql_error()); i'd like to display the first query results in one cell and the second query results in one cell. without copying the whole code twice and running into problems. How do i get round this? In short the full code works but when i duplicate it and change the query where clause, both queries don't work. But if i delete the duplicate it works again. Link to comment https://forums.phpfreaks.com/topic/197661-table-help/ Share on other sites More sharing options...
cags Posted April 5, 2010 Share Posted April 5, 2010 It doesn't work because you are assigning $construct a value that includes $construct, thus when you get to the second block of code you are reinserting the previous block. Simply re-naming the variable's should fix that issue. Link to comment https://forums.phpfreaks.com/topic/197661-table-help/#findComment-1037350 Share on other sites More sharing options...
MDanz Posted April 5, 2010 Author Share Posted April 5, 2010 thx for help, but not the problem. i'll try to explain it clearly.. i have the code it works. but when i duplicate the code in a different area of the page and change the where clause because i want different results on different areas of the page. i get the Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource. if i delete the duplicate, it works again. do you know what this error means? common mistakes? Link to comment https://forums.phpfreaks.com/topic/197661-table-help/#findComment-1037358 Share on other sites More sharing options...
cags Posted April 5, 2010 Share Posted April 5, 2010 Yes, the error means that mysql_query returned FALSE rather than a mysql resource object. It's what happens when you use an invalid syntax, which is what makes me think the error is as I described previously. echo mysql_error() directly after calling mysql_query to find out what exactly the error is. If you echo out $construct and the error then I'm sure the problem will be evident. Link to comment https://forums.phpfreaks.com/topic/197661-table-help/#findComment-1037359 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.