I am trying to write a PHP function to write error messages to an array. Not sure what I'm doing wrong, still trying to get to grips with functions.
I can make it work without functions, so I guess its the way I'm writing the function that is wrong.
function writeerrors($arr_key, $arr_val){
    $errors[$arr_key] = $arr_val;
    return;
}
Then I call it here when I check if the form field is empty. If it is empty I want it to write to the $errors array.
 //check if empty
                if(empty($fname)){
                    //write to error array
                  writeerrors('fname', 'Empty field - error');
                    //Flag
                    $errors_detected = true;
                }else {
Do something else ..}
This is the form... (ONLY TRYING TO VALIDATE FIRST NAME FIELD FOR NOW): http://titan.dcs.bbk.ac.uk/~mgreen21/p1_prac/PHP_BBK/P1/hoe9/index.php
 
    