经过一时间的 php + mssql,感觉 mssql 对编码的支持不是很好(其实还是自己没有把握好啦),但是又还没有来得急换数据库,只能将就点,今天又在提交数据时出现了错误。
由于提交的 ntext 字段的内容比较多,大约有 220 KB,所以造成了我的误解,以为是文章太长而引起的错误。我一看 php 配置,发现 php 对 mssql.textsize 的支持已经在 400 K了,怎么还出错?开启错误后才发现,原来不是文章太长,而是编码引起的错误。错误如下:
Notice: iconv() [function.iconv]: Detected an illegal character in input string in...。
英文实在太烂,只是知道 iconv() 函数出问题。google 翻译,说是输入字符串中检测到非法字符。恍然大悟。
根据错误提示到网上找到问题的解决办法,就是在 iconv() 的第二个参数加个 //IGNORE,就是忽略错误的意思,代码如下:
iconv("utf-8", "gbk//IGNORE", $str);
测试,提交成功。
注:网友经验,gbk 的范围比 gb2313 大,所以用 gbk 编码的出错率比 gb2313 小。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver Mac version
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software