in reply to mysql database

Showing the code is one step, but all you say about it is that you have a problem. But you don't say what it is. Does it crash? Does it print the wrong thing? (If so, what does it print?) Do you get errors? Does it return the wrong things from the database?

Also, you aren't checking whether your prepare succeeds; you aren't checking whether your execute succeeds, and you aren't using placeholders.

Abigail