Jump to content


Photo

Puzzling MySQL Error


  • Please log in to reply
2 replies to this topic

#1 korrupt03

korrupt03
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 09 October 2003 - 04:46 AM

We\'ve got a problem on our hands.. :roll:

Well okay, I run a flash portal on my site, http://www.stickslau....com/ss/portal/ and the current arrangement for the Staff animations isn\'t working..

Okay, well, I am attempting to create a page where it displays a staff members 3 latest animations, (http://www.stickslau...l/stafftest.php), then display a link to show all of their animations.. but.. mySQL gives off a weird errors.. here\'s what I\'m trying..

$sql = "SELECT * FROM $table WHERE user_id = \'1\' DESC LIMIT 3";

I know the table, select, from, and where are right, plus user_id is the correct table.. but it gives off a weird error. I need to include the DESC, which is suppose to display it in Descending order, or backwards, because if I just use:

$sql = "SELECT * FROM $table WHERE user_id = \'1\' LIMIT 3";

... it displays the list of 3 animations, but it\'s in oldest to newest, which doesn\'t work...

user_id =\'1\' is correct, because the user_id 1 is a staff animators number...

But if I take off the DESC, it works...

So basically, is their anyway to put it in DESC order, but use a WHERE..

Help! :shock:

8) KoRRupt

#2 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 09 October 2003 - 05:14 AM

Try this

substitue <filed_name> with what everr field you want to sort by.

$sql = "SELECT * FROM $table WHERE user_id = \'1\' order by <field_name> DESC LIMIT 3";

Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#3 korrupt03

korrupt03
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 09 October 2003 - 06:23 AM

Perfect! Thank you so much man!

I used the code you suggested... and substituted the fieldname with movie_date_uploaded, which worked great!

Thank you my friend, your a great help to this world of ours...

Peace 8)

P.S. If you care to see it all worked out, http://www.stickslau...l/stafftest.php :wink:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users