MySql insert binary data to db without errors(MySql将二进制数据插入db而不会出错)
问题描述
我有问题.当我在 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而不会出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySql将二进制数据插入db而不会出错
基础教程推荐
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何替换eregi() 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
