homepage Welcome to WebmasterWorld Guest from 23.23.57.144
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

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

5+ Year Member



 
Msg#: 3578442 posted 3:04 am on Feb 19, 2008 (gmt 0)

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

10+ Year Member



 
Msg#: 3578442 posted 3:10 am on Feb 19, 2008 (gmt 0)

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

5+ Year Member



 
Msg#: 3578442 posted 3:27 am on Feb 19, 2008 (gmt 0)

Yes I tried without quotes, still get the error.

bunltd

10+ Year Member



 
Msg#: 3578442 posted 4:05 am on Feb 19, 2008 (gmt 0)

LIMIT should be the last thing.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved