Hi All,
I am a bit stuck, and have been wondering whether there is a solution...
How can I return multiple values from a function?
I now return(true) upon succes of the function (Validation script).
So I can use it like: if(authorised(...)) {do something}
However, I would like to pass also a message from the function.
Is this at all possible? I was thinking about making the variable which is returned from the script an array, which should work, but I would prefer to return two seperate variables, one is the script status (true / false/error) and one is the message.
Thanks for any ideas,
Jelle.
[edit:}
the script so far:
function is_authorized($section, $action, $userid, $pageid)
{
global $pages_table, $manager_table;
$allpages = mysql_query("select * from $pages_table
left join $manager_table on Ma_p_nr = P_id
where (P_owner = $userid) or
(Ma_u_nr = $userid)") or die('The query had some mistakes in auth.q2: '.mysql_error());
while($row = mysql_fetch_array($allpages)) // Create an array with pages this user is allowed to edit
{
$allowed[$row['Ma_p_nr']] = true;
}
$editpagesections = array( // Create an array with the basic edit page actions
1 => true,
2 => true,
4 => true,
6 => true,
);
if($allowed[$pageid] and $editpagesections[$section])
{
return(true);
}
}