MYSQLI - WHERE IN array(MYSQLI - 数组中的位置)
问题描述
我在互联网上到处寻找有关此问题的答案,然后出现了准备好的语句和绑定参数(我不知道那是什么东西)
基本上,我有一个逗号分隔的列表
好的,现在我想在数据库的一列中搜索这些项目中的每一项......听起来很简单,对吧?
然后,
<块引用>
未定义变量
为什么?我看不出代码有什么问题.如果我输入一个特定的值,它会起作用,并且我已经使用 WHERE stuff=$item
对其进行了测试 - 效果很好.
所以不是变量/数据库,而是IN语句中的错误.我不明白为什么它不起作用.
每个元素都需要用引号括起来
或者如果你有一个数组
I've looked all over the internet for answers on this one, and prepared statements and bind params come up (I have no idea what that stuff is)
Basically, I have a comma separated list
Ok, now I want to search for each of those items in a column of the database... Sounds simple, right?
Then later on,
UNDEFINED VARIABLE
Why? I can't see anything wrong with the code. It works if I put a particular value, and I have tested it with WHERE stuff=$item
- that works fine.
So it's not the variables / database, it's an error in the IN statement. I don't understand why it won't work.
Each element needs quotes around it
Or if you had an array
这篇关于MYSQLI - 数组中的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!