Heim  >  Artikel  >  Backend-Entwicklung  >  请问这个单双引号的问题怎么处理?

请问这个单双引号的问题怎么处理?

WBOY
WBOYOriginal
2016-08-04 09:20:061158Durchsuche

<code>$current_account_url='<a class="mini-button" iconcls="icon-edit" onclick="printabc('html/达能益力贸易(深圳)有限公司-[101]广东
2016-04-01-2016-04-30对账单.html')">查看/打印1</a>'; 
</code>

要怎么才可以把它插入表中的字段里呢?搞了好久都没办法。。谢谢了

<code>$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'";</code>

回复内容:

<code>$current_account_url='<a class="mini-button" iconcls="icon-edit" onclick="printabc('html/达能益力贸易(深圳)有限公司-[101]广东
2016-04-01-2016-04-30对账单.html')">查看/打印1</a>'; 
</code>

要怎么才可以把它插入表中的字段里呢?搞了好久都没办法。。谢谢了

<code>$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'";</code>

我看你的SQL就有问题啊!变量你用单引号引用能把变量的值插入到数据库中吗?

\'转义。

你的语法没有问题,但是你在$current_account_url赋值的时候出现了问题.单双引号用错了
请问这个单双引号的问题怎么处理?
建议你使用定界符

请问这个单双引号的问题怎么处理?

插入之前用 php base64_encode 下 再插入
或者用mysql hex()之后再插入 避免这些问题

插入数据库可以实用反斜线转义,或者实用base64编码。
但我看你的问题好像是不知道怎么处理$current_account_url的单双引号嵌套。导致$current_account_url那一行一直出错。
嵌套方法也可以使用转义,或下面这样

<code>$current_account_url='<a class="mini-button" iconcls="icon-edit" onclick="printabc(' . " .>查看/打印1</a>'; </code>

谢谢各位,谢谢@yangxiangming提醒,用addslashes()转义后就可以插入正常读取了

运行的时候难道不报错吗?
$current_account_url="查看/打印1 ";
这样试试.

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn