Re: code not working...help?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 7 Oct 2004 14:14:10 -0400, Matthew <speakez@xxxxxxxxxxxxxxxxx> wrote:
> 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.
> 


Have you tried echo-ing your sql, and querying the database directly? 
That's where I usually start when I don't get the desired query
results.

You may also want to check your usage of $countRow.  If it contains an
array, and you're trying to access it without an index, you won't be
able to retrieve the count.  If that is the case, you can either
access the variable using $countRow[0] or change your retrieval
statement to read: list ($countRow) = db_fetch...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux