Link to home
Start Free TrialLog in
Avatar of j2
j2Flag for Sweden

asked on

Accessin array outside function?

I have a fuction that pulls an array from a mySQL database for Joomla!

But, how do i access that array outside my fucntion? My code doesnt work, as $rows is "NULL" when i try to act on it outside the function.
<?
defined('_VALID_MOS') or die('Direct access to this location not allowed');
 
getSessions();
//var_dump($rows);
foreach ( $rows as $row) {
	echo "$row->title $row->session_up\n";
}
 
function getSessions(){
	global $database;
	$sql= "select * from #__events_sessions where title like 'Stamps%' and session_down > now() order by session_up limit 1";
	$database->setQuery($sql);
	$rows = $database->loadObjectList();
	var_dump($rows);
//	foreach ( $rows as $row ) {
//		echo "$row->title $row->session_up\n";
//	}
	return $rows;
}
 
?>

Open in new window

Avatar of j2
j2
Flag of Sweden image

ASKER

Added missing row in code snippet.
ASKER CERTIFIED SOLUTION
Avatar of dr_dedo
dr_dedo
Flag of Egypt image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of j2

ASKER

*groooooaaaaaaaaaan*

I CAN NOT beleive i did that....

I was sure my problem was that i screwed up in calling a class from Joomla! incorrectly.

I am so embarrased.
Avatar of j2

ASKER

Thanks heaps!