name = '$row->name'"; //prints name correctly 我的字段名称 $next_row = db_query("select * from -6ren">
gpt4 book ai didi

Where 子句中的 PHP 变量字符串为空

转载 作者:行者123 更新时间:2023-11-29 19:27:32 26 4
gpt4 key购买 nike

echo "row->name = '$row->name'"; //prints name correctly

我的字段名称

$next_row = db_query("select * from field_data_field_department d join taxonomy_term_data t on d.field_department_tid = t.tid where d.entity_id = $entityID and t.name = '$row->name'");

返回未找到列:1054 Unknown Column 'Name of my field' in where 子句''

如果我在 MariaDB 中运行查询,它就会工作

select * from field_data_field_department d join taxonomy_term_data t on d.field_department_tid = t.tid where d.entity_id = 10568 and t.name = 'Name of my field';

最佳答案

可能与您正在访问对象的事实有关

(确保避免sql注入(inject))并尝试使用concat

  $next_row = db_query("select * 
from field_data_field_department d
join taxonomy_term_data t on d.field_department_tid = t.tid
where d.entity_id = $entityID and t.name = '" . $row->name ."'");

关于Where 子句中的 PHP 变量字符串为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42028682/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com