ORDER BY id DESC

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
elecktricity
Forum Contributor
Posts: 128
Joined: Sun Sep 25, 2005 8:57 pm
Location: Trapped in my own little world.
Contact:

ORDER BY id DESC

Post by elecktricity »

well I need it to order, I got it to only get rows with the coloum console to equal xbox, but I would like it to descent not ascend, I tried this but it kept giving me back an error.

Code: Select all

<?php
$dbh=mysql_connect ("localhost", "user", "password") or die ('Cannot connect to the database because: ' . mysql_error());
mysql_select_db ("databasename"); 
$query = sprintf("SELECT * FROM content WHERE console='xbox' ORDER BY id DESC",
   mysql_real_escape_string(xbox));

$result = mysql_query($query);

if (!$result) {
   $message  = 'Invalid query: ' . mysql_error() . "\n";
   $message .= 'Whole query: ' . $query;
   die($message);
}

while ($row = mysql_fetch_assoc($result))
{
   echo 'bla bla bla';
}

mysql_free_result($result);
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

mysql_real_escape_string(xbox) would generate a notice.
You aren't using the output of that function however.. I don't see any errors per se.. maybe you could post the details of it?
Post Reply