Re: code not working...help? Found problem =(

From: Date: Fri, 08 Oct 2004 04:16:15 +0000
Subject: Re: code not working...help? Found problem =(
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-198928@lists.php.net to get a copy of this message
Thanks these all helped me get some things working again... except one problem now... 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? -- Advanced Forums, For Free! - Speak EZ forums ( http://www.speakezforums.com ) "Graham Cossey" <graham@cossey.plus.com> wrote in message news:JGEHJJEPPLDNAPAHKDGGOEDGCKAA.graham@cossey.plus.com... > [snip] > > > > $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. > > Firstly, I've never come across the function db_query or db_fetch_array, > what are they? Are they 'home grown' or a readily available database > abstraction function set? (php.net function search returns no match) > > Secondly I find it easier (to read) to code my SQL statements thus: > > $countResult = db_query("SELECT count(*) AS msgCount FROM messages WHERE > uid='$userID' AND fid='$fid' AND > post_date<='$lastmonth'"); > > Finally, yes, echo the SQL statement so you know that all the variables are > being set correctly. > > $sql = "SELECT count(*) AS msgCount FROM messages WHERE uid='$userID' AND > fid='$fid' AND post_date<='$lastmonth'"; > echo "SQL statement = $sql "; > $countResult = db_query($sql); > $countRow = db_fetch_array($countResult); > echo "Result array = "; > print_r($countRow); > > HTH > Graham

« previous php.general (#198928) next »