devxtec Posted March 4, 2008 Share Posted March 4, 2008 I just finished writing up a very basic script to read information from the database. The following code is the original which works. <?php // This file relies on the parser file for its data. // Setup Database Variables $database = "####"; $server = "####"; $username = "####"; $password = "####"; // Update the database exec('bash /srv/www/htdocs/patch_update/parser', $returnedval); // echo $returnedval[0]; // Testing parser execution // Connect to the db server $connection = mysql_connect($server, $username, $password); if (!$connection) { die('Could not connect: ' . mysql_error()); exit; } // Select the correct database $db_selected = mysql_select_db($database, $connection); if (!$db_selected) { die ('Can\'t use customer : ' . mysql_error()); exit; } // Check to see if form submission occured. if(isset($submitted)) { } else { $query = "SELECT nabp, date, patch FROM versions"; $result = mysql_query($query); include "header.inc"; while($row = mysql_fetch_assoc($result)) { echo "\t\t<tr>\n"; echo "\t\t\t<td>".$row["nabp"]."</td>\n"; echo "\t\t\t<td>".$row["date"]."</td>\n"; echo "\t\t\t<td>".$row["patch"]."</td>\n"; echo "\t\t</tr>\n"; } include "footer.inc"; } ?> Now I want to change the way my data is outputted. So I changed my query from SELECT nabp, date, patch FROM versions to SELECT nabp, date, patch FROM versions ORDER by nabp, DESC date and it then displays this error. Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /srv/www/htdocs/patch_update/index.php on line 40 Line 40 is this while($row = mysql_fetch_assoc($result)) Just FYI the script isn't complete yet as I still need to finish one IF statement but I can't do this until I get my query working again. Any help would be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/94339-query-breaks-code-need-some-help/ Share on other sites More sharing options...
Barand Posted March 4, 2008 Share Posted March 4, 2008 DESC follows the col name SELECT nabp, date, patch FROM versions ORDER by nabp, date DESC Link to comment https://forums.phpfreaks.com/topic/94339-query-breaks-code-need-some-help/#findComment-483138 Share on other sites More sharing options...
devxtec Posted March 4, 2008 Author Share Posted March 4, 2008 DESC follows the col name SELECT nabp, date, patch FROM versions ORDER by nabp, date DESC Thanks for the quick reply. I totally didn't catch that I did that. Another pair of eyes always seems to help. Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/94339-query-breaks-code-need-some-help/#findComment-483159 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.