Great point in the between query!
It should be a >= b AND a <= c and not a>b and a<c
Sorry for the lack of knowledge, but when you say that it does not require a new prepare, how would that work?
How would I need to change the query so that $lip is updated?
Again, sorry for my lack of knowledge.