我需要PHP逃脱,MySQL逃脱。 MySQL转义包含星号和反斜杠。
我已经使MySQL转义部分正确并且MySQL查询正确运行。然而,我正在努力在PHP中正确地逃避MySQL转义"\*"
。
我试过看了几个没有成功的例子。
这是我的代码PHP代码:
$result = mysql_query("select * from (select Date,DocketNo,StockCode,Description,Quantity,Dept,DeptName,LineTotal,CustNo,CustomerName
from sales
where Date between '$datefrom' and '$dateto'
)
as T
right join cust_repcode
on cust_repcode.Customer = T.CustomerName
where RepCode ='$repcode'
and Date is not Null
and StockCode != '"\*"'
Order by Date");
答案 0 :(得分:0)
我不确定你是否需要在MySQL中逃避*,但如果需要,我会使用看起来更干净的CHAR()
方法
and StockCode != CHAR(42)