安装AppServ后首次使用mysql,没有图形界面,在“MySql Command Line Client”的操作如下:
======================================================================================
mysql> create database cars;
Query OK, 1 row affected (0.00 sec)
mysql> use cars;
Database changed
mysql> create table cars(id int,xm char(8),h char(8),vin char(20));
Query OK, 0 rows affected (0.06 sec)
mysql> insert into cars(id,xm,h,vin) values(1,'廉东方','豫A5F568','LDC666L2980790000');
Query OK, 1 row affected, 1 warning (0.02 sec)
mysql> select * from cars;
+------+------+----------+-------------------+
| id | xm | h | vin |
+------+------+----------+-------------------+
| 1 | | 豫A5F568 | LDC666L2980790000 |
+------+------+----------+-------------------+
1 rows in set (0.02 sec)
mysql> select xm from cars;
+------+
| xm |
+------+
| |
+------+
1 rows in set (0.00 sec)
mysql> update cars set xm='廉' where id=1;
Query OK, 0 rows affected, 1 warning (0.01 sec)
Rows matched: 1 Changed: 0 Warnings: 0
为何不能设置xm字段的值?为何无法更新?谢谢啦~~~
回复讨论(解决方案)
mysql> \W
Show warnings enabled.
mysql> update cars set xm='廉东方' where id=1;
Query OK, 0 rows affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
Warning (Code 1366): Incorrect string value: '\xC1\xAE\xB6\xAB\xB7\xBD' for colu
mn 'xm' at row 1
mysql> _
这里看插入数据的长度是6个字节,不到设计的8个字节,怎么就错了呢?
mysql> set names utf-8;
ERROR 1115 (42000): Unknown character set: 'utf'
mysql> set names utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> update cars set xm='廉' where id=1;
Query OK, 0 rows affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
Warning (Code 1366): Incorrect string value: '\xC1\xAE' for column 'xm' at row 1
mysql> _
还是不行,快急死了~~~
mysql> insert into cars(id,xm,h,vin) values(1,'廉东方','豫A5F568','LDC666L298079
0000');
Query OK, 1 row affected (0.00 sec)
mysql> select * from cars;
+------+--------+----------+-------------------+
| id | xm | h | vin |
+------+--------+----------+-------------------+
| 1 | 廉东方 | 豫A5F568 | LDC666L2980790000 |
+------+--------+----------+-------------------+
1 row in set (0.00 sec)
说一下你用的什么操作系统
刚开始学php,嫌配置麻烦,下个 appserv-win32-2.6.0.exe 直接安装的。
难道它安装的不合理?
电脑安装的是win7操作系统~~~
先执行 set names gbk; 应该就可以了
先执行 set names gbk; 应该就可以了
刚才查资料,有的说用:set names utf8;经测试不行,
但“set names gbk;”确实成功了,非常感谢!
能简单说一下为什么吗?
你 #1 的内容是我在#3回复后才看到的,不然一开始就解释了
\xC1\xAE\xB6\xAB\xB7\xBD 是 廉东方 的gbk 内码
而他却报错了,这说明你的数据库的默认字符集不是 latin1 的,也不是 gbk 的
那么对中文报错就只能是 utf8 的了(极少有人用 ucs-2 的,就算是也没关系)
对 utf8 字段插入 gbk 字符当然就要报错了
所以要 set names gbk 通知 mysql 现在用的是 gbk 字符
那么“豫”为什么没有报错呢?
这就要看 utf-8 是如何编码的了:
U+007F 0xxxxxxx
U+07FF 110xxxxx 10xxxxxx
U+FFFF 1110xxxx 10xxxxxx 10xxxxxx
U+1FFFFF 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
U+3FFFFFF 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
U+7FFFFFFF 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
豫 的gbk二进制内码为 11010100 10100101
正好符合 U+07FF 编码规则,所以他就不会报错
谢谢您的耐心回答,收获匪浅~~~

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Alipay PHP...


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download
The most popular open source editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool