Cheers for the assitance there kippesp
It actually turned out to be a typo on my behalf where:
PHP Code:
'FROM template AS t1'
wasnt on a new line but tacked on the end of :
PHP Code:
$templates=$DB_site->query("SELECT t1.title AS title,t2.templateid, NOT ISNULL(t2.templateid) AS found" . iif(isset($searchstring), ",INSTR(t1.".$searchtype.",'".addslashes($searchstring)."') AS globalcontain,INSTR(t2.".$searchtype.",'".addslashes($searchstring)."') AS localcontain","")."
So thanks again, its all working fine now.