Welcome to WebmasterWorld Guest from 50.19.53.104

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

You have an error in your SQL syntax; check the manual that correspond

     

tr8er8

3:04 am on Feb 19, 2008 (gmt 0)

5+ Year Member



Hi I get an error when I use the ORDER BY fucntion or whatever you wanna call it.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 'date' DESC' at line 1

This is what I have, with some extra parts that count the number of rows and some echos:

include('connect.php');

mysql_connect($mysql_server, $mysql_user, $mysql_password) or die(mysql_error());
mysql_select_db($mysql_database2) or die(mysql_error());

$result = mysql_query("SELECT * FROM $mysql_posts_table2 LIMIT 2 ORDER BY 'date' DESC")
or die(mysql_error());

It works until I put the ORDER BY section in. Any help?

[edited by: tr8er8 at 3:26 am (utc) on Feb. 19, 2008]

bunltd

3:10 am on Feb 19, 2008 (gmt 0)

10+ Year Member



SELECT * FROM $mysql_posts_table2 LIMIT 2 ORDER BY 'date' DESC

Did you try it like this:

SELECT * FROM $mysql_posts_table2 LIMIT 2 ORDER BY date DESC

I think the 'date' DESC is causing your trouble.
LisaB

tr8er8

3:27 am on Feb 19, 2008 (gmt 0)

5+ Year Member



Yes I tried without quotes, still get the error.

bunltd

4:05 am on Feb 19, 2008 (gmt 0)

10+ Year Member



LIMIT should be the last thing.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month