Just can't get it to work.. variables
| From: | Gavin Amm | Date: | Wed, 30 Mar 2005 04:18:57 +0000 |
| Subject: | Just can't get it to work.. variables | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-39067@lists.php.net to get a copy of this message | ||
Hi All,
I just can't for the life of me get the variable to output a value from
the array:
(all preceding script in place to make this work..)
The "start" date retrieved from the database is, for example, 20050412
(yyyymmdd).
The example output for each variable (w/o quotes) is:
$monthInt outputs "04"
$monthVal outputs ""
### CODE FOR DEBUGGING PURPOSES ###
while ($row = mysql_fetch_array($result)){
$monthName = array ("", "Jan", "Feb", "Mar",
"Apr", "May",
"Jun", "Jul", "Aug", "Sep", "Oct",
"Nov", "Dec");
$monthInt = substr($row['start'], 4, 2);
echo "\$monthInt = $monthInt<br>";
$monthVal = $monthName[$monthInt];
echo "\$monthVal = $monthVal<br>";
echo "<p><b>".$monthVal." ".substr($row['start'], 6,
2)."</b><br>\n".$row['details']."\n</p>\n\n";
}
### ORIGINAL CODE ###
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,
2)."</b><br>\n".$row['details']."\n</p>\n\n";
}
Cheers,
Gavin