无法获取列“format”的 SQL 查询
我似乎无法从 mySQL 数据中执行正确的选择。
$sort = $_GET['sort'];
// ...
$sql = "SELECT id, title, genre, format, year FROM dvd WHERE format LIKE '$sort%'";
$result = mysql_query($sql, $link);
<ul class="grid">
<?php
while ($row = mysql_fetch_assoc($result))
{ ?>
...
where $sort = 'dvd'
但是,当我尝试手动执行此操作时,
SELECT id, title,genre,format,year FROM dvd WHERE format LIKE 'dvd'
我能够使用 phpmyadmin 获得结果 -> mySQL-> SQL。
为什么我每次选择格式时都无法获取数据?
我在其他栏目(例如流派和标题)中尝试过此操作,并且能够得到我想要的结果。这些列均采用相同的 VARCHAR 结构和相同的设置
I can't seem to perform the proper selections from mySQL data.
$sort = $_GET['sort'];
// ...
$sql = "SELECT id, title, genre, format, year FROM dvd WHERE format LIKE '$sort%'";
$result = mysql_query($sql, $link);
<ul class="grid">
<?php
while ($row = mysql_fetch_assoc($result))
{ ?>
...
where $sort = 'dvd'
However, when i tried to do it manually,
SELECT id, title, genre, format, year FROM dvd WHERE format LIKE 'dvd'
i was able to obtain results using phpmyadmin -> mySQL -> SQL.
Why is it that i won't be able to get data whenever i choose format?
I tried this for other columns such as genre and title and i was able to get the result that i want. The columns were all structured to be the same VARCHAR and same settings
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
“格式”一词可能是一个冲突的关键字...将列名称“格式”更改为其他名称...它将起作用...
the word "format" might be a keyword which is conflicting... change the column name "format" to something else... It will work...
试试这个:
不要忘记 $sort 变量来自 $_GET 并且它必须是安全的
try this:
dont forget that $sort variable comes from $_GET and it must be secured
询问您的数据库,而不是询问不知道您的数据库发生了什么事的陌生人。
以这种方式运行您的查询
并查看它的内容。
Ask your database, not strangers who have no idea what's up with your database.
run your query this way
and see what it says.