问题描述
我有问题.当我在 php 中进行这样的插入时:
I have a problem. When I do an insert like so in php:
sql = "INSERT INTO mytable (id, value)
VALUES ('sds83','".$EncryptedString."')";
当我运行以下查询时,它有时有效,有时无效.问题是有时 $EncryptedString 包含这样的字符:')')这会导致语法错误.$EncryptedString 包含二进制数据,我该如何解决这个问题?
When I run the following query it sometimes works and sometimes it doesn't. The problem is that sometimes the $EncryptedString contains characters like this: ')') which causes syntax errors. The $EncryptedString contains binary data, how can I go about this issue?
推荐答案
转义你的加密字符串
mysql-real-escape-string
mysql_real_escape_string() 调用 MySQL 的库函数mysql_real_escape_string,将反斜杠添加到以下内容字符:x00、 、 、、'、" 和 x1a.
mysql_real_escape_string() calls MySQL's library function mysql_real_escape_string, which prepends backslashes to the following characters: x00, , , , ', " and x1a.
参见 StripSlashes
这篇关于MySql将二进制数据插入db而不会出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)