Query doesn't work inside a function

前端 未结 5 923
一生所求
一生所求 2021-01-25 09:27

Well, I have this function in a custom script for SMF:

$query = \"SELECT id_member, real_name, id_group FROM smf_members WHERE id_group > 0 AND id_group != 9          


        
5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-25 10:02

    Your function doesn't do anything: It assigns a value to a local variable, and then does nothing with the value and the variable. It should either return it (the value) or execute the query.

    Also note that doing string concatenation to put the variable in the query is creating a security hole: http://bobby-tables.com/

    You should consider using mysqli and parametrized queries as suggested here: http://bobby-tables.com/php.html

    At the very least, consider quoting the values you include in the query with the functions provided by PHP to do so. All values. But parametrized queries are better and easier.

提交回复
热议问题