Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
dream2rule
- Forum Contributor
- Posts: 109
- Joined: Wed Jun 13, 2007 5:07 am
Post
by dream2rule »
Hello All,
I have this query which when written does not execute, PHPMyAdmin says it to be an error.
Code: Select all
SELECT * FROM user_ip_tracking ORDER BY ip_id WHERE date_of_access BETWEEN '$start_date' AND '$end_date'
where $start_date = 2007-08-15
$end_date = 2007-08-29
This query does not work.. can i know where am i going wrong?
Thanks & Regards,
Dream2rule
-
aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Post
by aceconcepts »
what's the error you get?
-
volka
- DevNet Evangelist
- Posts: 8391
- Joined: Tue May 07, 2002 9:48 am
- Location: Berlin, ger
Post
by volka »
If you don't get an error message yet your script is lacking error handling. At least add something like
Code: Select all
$query = 'your sql statement';
$result = mysql_query($query);
// basic error handling
if ( false===$result) die (htmlentities(mysql_error().': '.$query));
hint: SELECT ... WHERE ... ORDER BY
see
http://dev.mysql.com/doc/refman/5.1/en/select.html
Last edited by
volka on Fri Aug 31, 2007 8:02 am, edited 1 time in total.
-
VladSun
- DevNet Master
- Posts: 4313
- Joined: Wed Jun 27, 2007 9:44 am
- Location: Sofia, Bulgaria
Post
by VladSun »
ORDER BY is missplaced
There are 10 types of people in this world, those who understand binary and those who don't
-
dream2rule
- Forum Contributor
- Posts: 109
- Joined: Wed Jun 13, 2007 5:07 am
Post
by dream2rule »
Yeah.. I had written ORDER BY.. after the WHERE clause in the sql query..
Now it works fine.. Thankyou!
