thanks for your help but i think i got it.
maybe i should learn that if the query is in a function i have to grab the global var that is $member table
added this:
global $membertable;
no more errors, sorry again 😃
i used to think that any vars defined out of the functions was automatically globalised so anywhere in the script you could access them, i suppose in a function you can have multiple vars of the same name but they dont cross each others paths