PHP 内爆引用字符串
$brand_condition = ' AND ' . mysql_real_escape_string($brand_selection) . ' IN ';
$brand_condition .= $quote10 . '"'. mysql_real_escape_string($brand_value) . '"' .$quote9;
$brand_conditions[] = $brand_condition;
$query .= implode(' AND ', $brand_conditions) . '';
这会产生: ANDManufacturerIN("brand1,brand2")
由于我使用 IN 语句,因此我需要引用这些值。同时,我使用 mysql_real_escape_string 转义潜在的引号。
有谁看到一个简单的方法来解决这个小问题?
$brand_condition = ' AND ' . mysql_real_escape_string($brand_selection) . ' IN ';
$brand_condition .= $quote10 . '"'. mysql_real_escape_string($brand_value) . '"' .$quote9;
$brand_conditions[] = $brand_condition;
$query .= implode(' AND ', $brand_conditions) . '';
This produces: AND manufacturer IN ("brand1,brand2")
Since I'm using the IN statement, I need the values to be quoted. At the same time, I am escaping potential quotes with mysql_real_escape_string.
Does anyone see a simple way to get around this small problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
或者
or
$brand_conditions[] = '"'.$brand_condition.'"';
怎么样,以便在数组中添加 Brand_condition 之前添加引号。How about
$brand_conditions[] = '"'.$brand_condition.'"';
so your adding quotes right before you add the brand_condition in your array.使用它为内爆字符串添加引号。
$values = implode( " ',' ", array_values($values) );
Use this to add quotes for imploded string.
$values = implode( " ',' ", array_values($values) );