Yeah, I ended up doing that (associative array) then reading your
e-mail.. Oh well, thanks.
I couldn't cast the var as an int. in the database it's setup as a
timestamp(8) (yyyymmdd), not sure why I set it up as such..


-----Original Message-----
From: Martin Norland [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 31, 2005 12:43 AM
Subject: Re: [PHP-DB] Re: Just can't get it to work.. variables

David Robley wrote:
> Gavin Amm wrote:
> That would indicate that you are actually saying:
>  $monthVal = $monthName[04];
> where the 04 is actually a string; you have no element '04' in your 
> array. Cast $monthInt to an integer before you use it as an array 
> element.
> Alternatively, if you are using MySQL, you can use DATE_FORMAT to 
> achieve the same result.
>>while ($row = mysql_fetch_array($result)){
>>$monthName = array ("", "Jan", "Feb", "Mar", "Apr", "May", "Jun", 
>>"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); echo 
>>"<p><b>".$monthName[substr($row['start'], 4, 2)]." 
>>".substr($row['start'], 6, 

Yep, also - no need to redeclare $monthName each iteration.  If you 
wanted you could also just declare it thusly:

$monthName = array ("01" => "Jan", "02" => "Feb", "03" => "Mar", "04" =>

"Apr", "05" => "May", "06" => "Jun", "07" => "Jul", "08" => "Aug", "09" 
=> "Sep", "10" => "Oct", "11" => "Nov", "12" => "Dec");

... incidentally, Oct/Nov/Dec should have worked previously afaik, PHP 
is fairly forgiving.  You can probably also get away with just using 
round() to get your integers where you need them, instead of the 
declaration above.

- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to