Page 1 of 1

Between Query in MYsql is not working

Posted: Fri Aug 31, 2007 4:19 am
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

Posted: Fri Aug 31, 2007 7:51 am
by aceconcepts
what's the error you get?

Posted: Fri Aug 31, 2007 8:00 am
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

Posted: Fri Aug 31, 2007 8:02 am
by VladSun
ORDER BY is missplaced

Posted: Sat Sep 01, 2007 1:48 am
by dream2rule
Yeah.. I had written ORDER BY.. after the WHERE clause in the sql query..

Now it works fine.. Thankyou! :)