Re: code not working...help?
| From: | Matthew Kiehne | Date: | Fri, 08 Oct 2004 04:48:13 +0000 |
| Subject: | Re: code not working...help? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-198931@lists.php.net to get a copy of this message | ||
i just realized that the dates in the database are saved as
varchar (althought they are numbers) is there anyway to compare the
$lastmonth value (which returns as a 14 digit number) to that because the
way i have it now with
> post_date <= '$lastmonth'
wont work because post_date is varchar and $lastmonth is an interger right?
"Matthew" <speakez@speakezforums.com> wrote in message
news:20041007181505.27391.qmail@pb1.pair.com...
> Hi guys im pretty new at this and cant seem to get this going.... I want
the
> code to query the database for the number of messages posted within the
last
> month this is the code i have but its not working... I might even have it
> all wrong, can someone point me in the right direction?
>
> $lastmonth = date("YmdHis", mktime(date("H"), date("i"),
> date("s"),
> date("m")-1, date("d"), date("Y")));
> $countResult = db_query("SELECT count(*) AS msgCount FROM messages WHERE
> uid = '". $userID ."' AND fid = '". $fid ."' AND
> post_date <= '".
$lastmonth
> ."'");
> $countRow = db_fetch_array($countResult);
>
> im then using $countRow as my variable but it keeps returning a value of
> zero.