[英]How search in php mysql query in where condition column_name='bolt 1/2 inch'
I have a column in a db table that contains 'bolt 1/2 inch' 我在数据库表中有一列包含“螺栓1/2英寸”
i got hanged when passing forward slash in the variable. 在变量中传递正斜杠时,我被绞死了。 If there is no slash then it code is working fine.
如果没有斜杠,那么它的代码工作正常。
$par_stockDescription = 'bolt 1/2 inch'
$description = mysql_real_escape_string($par_stockDescription);
$sql_getStockId = "SELECT stock_id,units FROM table_name WHERE description ='".$description ."';
$result_stockId =db_query($sql_getStockId);
$arr_stockId = db_fetch($result_stockId);
echo $arr_stockId['stock_id'];
您的字符串配额不正确,请使用以下命令:
$sql_getStockId = "SELECT stock_id,units FROM table_name WHERE description ='".$description ."'";
将查询更改为以下内容
$sql_getStockId = "SELECT stock_id,units FROM table_name WHERE description ='".$description ."'";
This should be your query: 这应该是您的查询:
$sql_getStockId = "SELECT stock_id,units FROM table_name WHERE description ='".$description ."'";
Also mysql_real_escape_string has been deprecated consider mysqli or pdo 另外不建议使用mysql_real_escape_string,请考虑使用mysqli或pdo
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.