Home > Archive > PHP DB > March 2005 > RE: [PHP-DB] Re: Just can't get it to work.. variables
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
RE: [PHP-DB] Re: Just can't get it to work.. variables
|
|
| Gavin Amm 2005-03-31, 3:57 am |
| 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][color=darkred]
> 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
| |
| David Robley 2005-03-31, 3:57 am |
| Gavin 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
|
|
|
|
|