I am calling a function in the following way from my functions.php page which I'm including using include ('functions.php');
$sql = "Select lastUpdate from revised";
$result = mysql_query($sql);
$revised = mysql_fetch_row($result);
echo "Last Revised: " .format_date($revised)."";
function format_date($revised){
$date = explode("-", $revised);
$year = $date[0];
$month = $date[1];
$day = $date[2];
switch ($month){
case "01":
$month = "January";
break;
case "02":
$month = "February";
break;
case "03":
$month = "March";
break;
case "04":
$month = "April";
break;
case "05":
$month = "May";
break;
case "06":
$month = "June";
break;
case "07":
$month = "July";
break;
case "08":
$month = "August";
break;
case "09":
$month = "September";
break;
case "10":
$month = "October";
break;
case "11":
$month = "Novemeber";
break;
case "12":
$month = "December";
break;
}
$formatDate = "$month $day, $year";
return $formatDate;
}
The function returns the correct value only if I set $revised inside the function like this:
function format_date($revised){
$revised = "2005-09-11";
$date = explode("-", $revised);
$year = $date[0];
$month = $date[1];
$day = $date[2];
etc....
if I call it the way I want to in the first example all I get back is this:
Last Revised: , Array
Why?
Any help is appreciated.
Thanks