Can anyone explain what is wrong with this function [SOLVED]

Will do. Thanks