Please don't lough this is a serious blow to my ego. I've programmed in Basic, Pascal, C++, C# and in all these languages variables that are declared out of the function scope can not be used within the function. Php is of course no exception to this rule. This was a day I could have better gone for a walk in the park with my dog...
It's solved now.....