Page 1 of 1

ORDER BY id DESC

Posted: Mon Oct 03, 2005 2:17 pm
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);
?>

Posted: Mon Oct 03, 2005 3:12 pm
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?