Mysqli SELECT ? (bind_param)

前端 未结 2 1196
遥遥无期
遥遥无期 2021-01-24 17:47

I am trying to query the data in a column dependent on the variable $garment. The query works until I try to bind the parameter $garment . Any idea what I\'m doing wrong?

<
2条回答
  •  离开以前
    2021-01-24 18:05

    That happens because with prepared statements you only can build values (not identifiers). That's it

    SELECT ? 
    

    becomes

    SELECT 'somevalue'
    

    The first code is the correct one but to be safe you must ensure that the $garment variable value is whitelisted.

提交回复
热议问题