当前位置:网站首页>MySQL数据库‘反斜杠\’ ,‘单引号‘’,‘双引号“’,‘null’无法存储
MySQL数据库‘反斜杠\’ ,‘单引号‘’,‘双引号“’,‘null’无法存储
2022-07-31 22:15:00 【小苗吃不够】
MySQL数据库‘反斜杠\’ ,‘单引号’'’,‘双引号""’,‘null’无法存储,\ ’ " null 字符被过滤
问题原因:
在mysql中这些字符被当做成了转义字符(单引号,双引号,反斜杠,null);
比如我们在写SQL语句时不管是查询修改还是新增,比如是一些文字或者数字都可以正常的进行查询和新增等,但是如果一旦里边包含了特殊字符,比如说要插入“今天下雨了\今天没下雨” 这里的反斜杠会被当成转义字符稀释掉,到了数据库内就是“今天下雨了今天没下雨”,这里类似于过滤掉了一样;
解决方式:
PHP addcslashes()函数
该函数要求PHP版本4+
addcslashes() //函数返回在预定义的字符前添加反斜杠的字符串。
//提示:该函数可用于为存储在数据库中的字符串以及数据库查询语句准备合适的字符串。
预定义字符是:
单引号(')
双引号(")
反斜杠(\)
NULL
该函数会对这些预定义字符前添加反斜杠\
$name = '小红\小蓝';
$name = addcslashes($name);
//这里的name值为 小红\\小蓝
//在数据库存储时第一个 \ 被当做转义字符
这个时候存储就不会有问题了;
将插入到mysql内的字符进行转义的实质是:将php中的特殊字符如(‘’,“”,, null)插入到数据库。
边栏推荐
- SiC MOSFET的短路特性及保护
- LevelSequence source code analysis
- Qualcomm cDSP simple programming example (to query Qualcomm cDSP usage, signature), RK3588 npu usage query
- 【公开课预告】:超分辨率技术在视频画质增强领域的研究与应用
- OSPFv3的基本配置
- The old music player WinAmp released version 5.9 RC1: migrated to VS 2019, completely rebuilt, compatible with Win11
- 有一说一,外包公司到底值不值得去?
- What is Thymeleaf?How to use.
- Payment module implementation
- 【论文精读】iNeRF
猜你喜欢

The latest masterpiece!Alibaba just released the interview reference guide (Taishan version), I just brushed it for 29 days

Redis Overview: Talk to the interviewer all night long about Redis caching, persistence, elimination mechanism, sentinel, and the underlying principles of clusters!...

Shell script quick start to actual combat -02

iNeuOS industrial Internet operating system, equipment operation and maintenance business and "low-code" form development tools

NVIDIA已经开始测试AD106和AD107 GPU核心的显卡产品

flowable workflow all business concepts

Implementing a Simple Framework for Managing Object Information Using Reflection

Structure of the actual combat battalion module eight operations

【论文精读】iNeRF

Count characters in UTF-8 string function
随机推荐
cas and spin locks (is lightweight locks spin locks)
Document management and tools in the development process
NVIDIA has begun testing graphics products with AD106 and AD107 GPU cores
Architecture Battalion Module 8 Homework
Pytest初体验
全网一触即发,自媒体人的内容分发全能助手——融媒宝
关注!海泰方圆加入《个人信息保护自律公约》
如何减少软件设计和实现之间鸿沟
支付模块实现
Getting Started with Tkinter
Student management system on the first day: complete login PyQt5 + MySQL5.8 exit the operation logic
Recognize anomalies (you will understand after reading this)
"SDOI2016" Journey Problem Solution
Arduino框架下STM32全系列开发固件安装指南
HTC使用官方固件作为底包制作rom卡刷包教程
UserAgent resolution
sqlite3 simple operation
ThreadLocal
The difference between adding or not adding the ref keyword when a variable of reference type is used as a parameter in a method call in C#
BOW/DOM (top)