我的数据库表中有一个列包含“ bolt 1/2 英寸”
在变量中传递正斜杠时,我被绞死了。如果没有斜杠,则代码工作正常。
$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 ."'";
关于php - 如何在php mysql查询中搜索where条件column_name ='bolt 1/2 inch',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23239865/