Page 1 of 1

mysql error

Posted: Mon Sep 17, 2007 10:15 pm
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?

Posted: Mon Sep 17, 2007 10:18 pm
by VladSun
ORDER BY is after WHERE clause

Posted: Sat Sep 22, 2007 10:00 am
by JackV
Hi ,

Also it's good practise to not use SELECT * , actually specify the columns

Posted: Sat Sep 22, 2007 10:06 am
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.