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. Quote Link to comment 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 Quote Link to comment 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. 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.