Hey all
I tried searching for a solution to my problem, but I could find any examples that matched my situation...
I have a function which pulls a single row from a table, and want to put the values into an array, and return that array so that it comes available to the script calling the function.
function GetCubeDetails($cid) {
global $CFG;
$db = mysql_connect("$CFG->dbhost", "$CFG->dbuser", "$CFG->dbpass");
mysql_select_db("$CFG->dbname",$db);
$list_cube = "SELECT * FROM cube WHERE cube_id = '$cid'";
$list_cube_result = mysql_query( $list_cube ) or die ( "Error fetching cube..." );
while ($mycube = mysql_fetch_array($list_cube_result)) {
$get_p_cube = "SELECT p_cid, auth FROM p_cube WHERE p_cid = '$mycube[cid]'";
$get_p_cube_result = mysql_query( $get_p_cube ) or die ( "Error fetching parent cube..." );
while ($my_parent = mysql_fetch_array($get_p_cube_result)) {
$parent_cube = "$my_parent[auth]";
}
$this_cid = array ( 'cube_height' => "$mycube[cube_height]",
'cube_color' => "$mycube[cube_color]",
'cube_mass' => "$mycube[cube_mass]",
'admin_org' => "$parent_cube",
'cube_state' => "$mycube[cube_state]");
}
//print_r($this_cid);
return $this_cid;
}
when I uncomment print_r, I can see the contents of the array in the script that calls the function.
However, when try to print_r the returned array from with the script that calls the function, I get nothing.
Now I'm kinda new to PHP. I can do the regular PHP-stuff, but I'm probably missing something here.
Any1 here that can help me out?
thx!