
January 5th, 2004, 11:57 PM
|
 |
Contributing User
|
|
Join Date: Nov 2002
Location: New York City
Posts: 236
Time spent in forums: 1 Day 1 h 50 m 36 sec
Reputation Power: 17
|
|
I found out what was wrong. I echoed out currentdate and endofmonth variables again and I then remebered after viewing it that getdate() months come back as 1 not 01 (in the case of January). So I added a switch statement that has Case 10,11, 12 keep as is, if month equal to 1-9 make month= 01-09
PHP Code:
switch($month)
{
case 10:
case 11:
case 12:
$currentmonth = $year.'-'.$month.'-00';
$endofmonth = $year.'-'.$month.'-31';
break 1;
default:
$currentmonth = $year.'-0'.$month.'-00';
$endofmonth = $year.'-0'.$month.'-31';
}
I havn't finished fully testing all of it yet, but so far seems to be working ok now
Quote:
There is nothing wrong with using BETWEEN as long as you use it correctly.
mysql_query("SELECT * FROM calendar WHERE start_date BETWEEN '$currentdate' AND 'endofmonth'
change that to
mysql_query("SELECT * FROM calendar WHERE start_date BETWEEN $currentdate AND $endofmonth
And it should work then.
|
if you put php variables inside a select statement with out them being surrounded by single quotes you WILL get a parse error because MySQL thinks they are a string instead of variables. (Look, I actually knew something ahead of time, WOW  )
|