Code Comments
Programming Forum and web based access to our favorite programming groups.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..
Cheers,
Gavin
-----Original Message-----
From: Martin Norland [mailto:martin.norland@stjude.org]=20
Sent: Thursday, March 31, 2005 12:43 AM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Re: Just can't get it to work.. variables
David Robley wrote:
> Gavin Amm wrote:
[snip]
> That would indicate that you are actually saying:
> $monthVal =3D $monthName[04];
>=20
> where the 04 is actually a string; you have no element '04' in your=20
> array. Cast $monthInt to an integer before you use it as an array=20
> element.
>=20
> Alternatively, if you are using MySQL, you can use DATE_FORMAT to=20
> achieve the same result.
>=20
Yep, also - no need to redeclare $monthName each iteration. If you=20
wanted you could also just declare it thusly:
$monthName =3D array ("01" =3D> "Jan", "02" =3D> "Feb", "03" =3D> "Mar", =
"04" =3D>
"Apr", "05" =3D> "May", "06" =3D> "Jun", "07" =3D> "Jul", "08" =3D> =
"Aug", "09"=20
=3D> "Sep", "10" =3D> "Oct", "11" =3D> "Nov", "12" =3D> "Dec");
... incidentally, Oct/Nov/Dec should have worked previously afaik, PHP=20
is fairly forgiving. You can probably also get away with just using=20
round() to get your integers where you need them, instead of the=20
declaration above.
cheers,
--=20
- Martin Norland, Sys Admin / Database / Web Developer, International=20
Outreach x3257
The opinion(s) contained within this email do not necessarily represent=20
those of St. Jude Children's Research Hospital.
--=20
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Post Follow-up to this messageGavin Amm wrote: > 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.. > > Cheers, > Gavin I guess I didn't fully explain that I meant cast as an int in php :-) David
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.