sql语句的单双引号问题

时间:2023-03-08 23:41:46
sql语句的单双引号问题
$current_account_url='<a class="mini-button" iconcls="icon-edit"
onclick="printabc('html/达能益力贸易(深圳)有限公司-[101]广东
2016-04-01-2016-04-30对账单.html')">查看/打印1</a>'; 
$sql_url="update tools_current_account set current_account_url='$current_account_url'
where Current_unit='$current_unit' and status=1 AND
starttime='$starttime' and endtime='$endtime'";

单双引号的处理很麻烦,两条语句本身是正确的,但是放在一起就出错了。

解决办法:用addslashes()转义$current_account_url后再拼接sql就可以了