I’m trying to make a prepared query that can be used to select any number of users, and also filter them from a basic search functionality.
It looks like this:
$ALL_MEMBERS = $database->prepare("SELECT * FROM Users WHERE Username LIKE '%?%' LIMIT ?, ?")
But PDO doesn’t seem to be picking up that first ‘?’ inbetween the ‘%’s. Any idea why?
(It gives me an error when I give 3 parameters, saying there’s the wrong amount, whereas it doesn’t when giving two parameters)
You are likely confusing PDO there with the quotes and percentages, it is looking for a ? mark. Write it as:
And then have the first variable as: