FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Help with mysql query





ammonkc
I need some help with this mysql query.

this is the query:

Code:
SELECT * FROM request_status AS s INNER JOIN requests AS req ON s.requestID = req.requestID INNER JOIN users AS usr ON req.usrEmail = usr.usrEmail WHERE status = 'pending' AND DATE(dateSubmitted) BETWEEN '2005-12-01' AND '2005-12-05' ORDER BY dateSubmitted


I keep getting this 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 '(dateSubmitted) BETWEEN '2005-12-01' AND '2005-12-05' ORDER BY

the 'dateSubmitted' field is an INT and has a unix timestamp that I made in my php script like this:
Code:

$dateM=date("m",strtotime("now"));
$dateD=date("d",strtotime("now"));
$dateY=date("Y",strtotime("now"));

$dateTS=mktime(0,0,0,$dateM,$dateD,$dateY);

what am I doing wrong with this query? I am using mysql 4.1
raver
well...maybe it`s just me....but take a close look at the date you are using...for one thing your time is M, D, Y but your SQL INSERT statement tries to add a Y, M, D format. Try changing it and see if it works.
ammonkc
raver wrote:
or one thing your time is M, D, Y but your SQL INSERT statement tries to add a Y, M, D format. Try changing it and see if it works.


I fixed that and still I get the same error. it seems like mysql doesn't like me using DATE() on that field, or any field for that matter. any ideas?
ammonkc
it seems like the problem is with the DATE() function in mysql. if I just to a comparison on the timestamps. it works fine. but I don't know why it wont let me format the timestamp into a DATE().
Related topics
MySQL connection
PHP/Mysql - beginner!
mySQL Query/PHP code - get the highest value...
What is wrong with this MySQL query?
[Edit] mySQL Count
PHP MySQL Question
mysql insert into multiple tables at once?
whats wrong with this mysql query?
Looping through multiple mysql results
MySQL Query help
MySQL Query Cache
what is wrong with this query? Please please help!
mysql query based on 2 fields using 3 different tables
PHP and Javascript Issue handling data from a mysql query
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.