如何在mysql查询中添加引号? [英] How to add quotes in mysql query?
本文介绍了如何在mysql查询中添加引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个
I have this
if ($_POST["manufacturers"]) {
$where = addWhere($where, "make IN (".htmlspecialchars(implode(",", $_POST["manufacturers"])).")");
}
$sql = "SELECT * FROM vehicles";
if ($where) {
$sql .= " WHERE $where";
}
echo $sql;
我得到的mysql查询是:
mysql query i get is:
SELECT * FROM vehicles WHERE make IN (Tesla,Ford);
此查询不起作用,因为没有引号。示例('特斯拉','福特')。
例如,如果列值是一个数字,例如id,那么它将起作用。那么,如何在括号中的值之间添加引号?
我尝试过的事情:
尝试更改括号中的列名和值。如果括号内的数字是数字而不是查询工作。
This query doesn't work because there's no quotation marks. Example ('Tesla','Ford').
For example if column value was a number, for example id, then it would work. So, how can i add quotation marks between values in parentheses?
What I have tried:
Tried changing column name and values in parentheses. If values inside of the parentheses are numbers than query works.
推荐答案
_POST [制造商]){
_POST["manufacturers"]) {
其中= addWhere(
where = addWhere(
where,make IN(.htmlspecialchars(implode(,,
where, "make IN (".htmlspecialchars(implode(",",
这篇关于如何在mysql查询中添加引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文