Re: Why Doesn;t this Date Query Work?
Fantastic! This was indeed the problem and has solved it. Many thanks! On Tue, 24 Feb 2004 13:14:51 +0100, Jigal van Hemert wrote: >> $sql = 'SELECT Username, Count( Username ) FROM MainDetails, Usernames >> WHERE MainDetails.UserID = Usernames.UserID and Date Between \'$Date1\' >> and \'$Date2\' GROUP BY Username'; >> >> The strange thing is if I replace the $Date2 variable with a date manually >> it works -. i.e. > > Not a MySQL issue, but an error in your PHP code. Single quotes do NOT > replace variables with their values, > so if you use double quotes: > $sql = "SELECT Username, Count( Username ) FROM MainDetails, Usernames > WHERE MainDetails.UserID = Usernames.UserID and Date Between '$Date1' and > '$Date2' GROUP BY Username"; > it will work. > > Regards, Jigal -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Why Doesn;t this Date Query Work?
Hello All, I have a very strange problem which makes no sense to me whatsoever. I am trying to find the number of queries that the people have dealt with in a database between two dates. The dates are generated from some drop down boxes and dropped into a variable. This is the code for the query. $sql = 'SELECT Username, Count( Username ) FROM MainDetails, Usernames WHERE MainDetails.UserID = Usernames.UserID and Date Between \'$Date1\' and \'$Date2\' GROUP BY Username'; The strange thing is if I replace the $Date2 variable with a date manually it works -. i.e. $sql = 'SELECT Username, Count( Username ) FROM MainDetails, Usernames WHERE MainDetails.UserID = Usernames.UserID and Date Between \'$Date1\' and \'2004-01-01\' GROUP BY Username'; This would indicate that the variable is wrong but it is not. The code to generate the variable is exactly the same as $Date1 further more it echos on screen and is creating the date in the format as entered in the manual version? Any ideas? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]