嗨我在php文件中有一个查询,用于过滤mysql数据库中的数据
$_SESSION['sc_session'][$this->Ini->sc_page]['grid_deposit']['where_orig'] = " where Reg_no = \"69\"";
在此行中如果Reg_no = \“69 \”“,如果我将69更改为任何值正在修改数据,但如果我使用的是数组而不是69,那么它不能像这样工作
$_SESSION['sc_session'][$this->Ini->sc_page]['grid_deposit']['where_orig'] = " where Reg_no = " . $fc . "";
但如果我使用 $ fc = 69; echo $ fc;
然后它的工作但不在那一行请告诉我如何编码这个我得到的错误是
Error
Error while accessing the database:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
select count(*) from deposit where Reg_no =
答案 0 :(得分:1)
和你的Reg_no =“。$ fc。”“;
你是不是错过了$ fc
的“” $_SESSION['sc_session'][$this->Ini->sc_page]['grid_deposit']['where_orig'] = " where Reg_no = \"" . $fc . "\"";
匹配你的69个例子。
答案 1 :(得分:1)
在原始问题中,您说明了此错误文字
Error
Error while accessing the database:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
select count(*) from deposit where Reg_no =
如果$ fc是一个数组,你会在查询中看到这个。如果我没记错的话,那就像是......
Error
Error while accessing the database:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
select count(*) from deposit where Reg_no = Array
因为它不是我假设变量$ fc是空的。您是否检查了变量或更好地创建查询并将其记录在某处以检查查询,因为它被发送到sql server。
如上所述,如果它是一个数组,PHP会在错误地使用它时将其转换为您应该在查询中找到的文本“Array”。
答案 2 :(得分:0)
我想你会尝试做类似
的事情“Reg_no IN(”。implode(“,”,$ fc)。“)”;