I am using the following code as part of a function on my site. This is a snippet - of course the function contains a lot more information, however that is not relevant to my cu