You can't bind columns (or tables) from doing a SELECT
as you have in SELECT ?
.
- Select an actual column.
Or, if you want to do it dynamically, you need to use a variable.
Example: SELECT $type
<= that is allowed.
However, column names can be binded when using a WHERE
clause.
Example: SELECT column FROM table WHERE column=?
which you are presently using => WHERE id=?
Consult the manual on bind_param()
Footnotes:
If you happen to use an MySQL reserved word (it could happen), you will need to wrap your column's variable with backticks.
For example: (if using $type="from";
) "from" being a reserved word.
SELECT `$type` FROM members WHERE id=?
For a list of MySQL reserved words, visit the following page: