mysql error

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

mysql error

Post by psychotomus »

error: 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 'WHERE prayer_date>='1189998899'' at line 1

code:

Code: Select all

$time = 60 * 60 * 24;
$time = time() - $time;
$result = mysql_query("SELECT * FROM prayers ORDER BY priority ASC, prayer ASC WHERE prayer_date>='$time'") or die(mysql_error());

I can't seem to figure out what the problem is. =( maybe because of Where i have the WHERE at?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

ORDER BY is after WHERE clause
There are 10 types of people in this world, those who understand binary and those who don't
JackV
Forum Newbie
Posts: 6
Joined: Sat Sep 22, 2007 9:26 am

Post by JackV »

Hi ,

Also it's good practise to not use SELECT * , actually specify the columns
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

JackV wrote:Hi ,

Also it's good practise to not use SELECT * , actually specify the columns
If you need all the columns, whats wrong with *? It is perfectly acceptable in my books.
Post Reply