gpt4 book ai didi

PHP 和 MySQL : Store and print hex char

转载 作者:行者123 更新时间:2023-11-29 03:14:03 26 4
gpt4 key购买 nike

我试图在 MySql 数据库中存储一个十六进制值 (\xC1)。当我用 PHP 打印时,我得到:xC1lcool 而不是正确的词。

INSERT INTO veiculos VALUES (1, 'Ford', 'Ka RoCam Flex', 25850.00, 1998, 1999, 'Vermelho', 15000, '\xC1lcool;Gasolina;GNV', 'Ar-Condicionado;4 portas;Câmbio automático', 'imagem1.jpg;imagem2.jpg;imagem3.jpg;imagem4.jpg;imagem5.jpg;'), (2, 'Ford', 'Ka RoCam Flex', 223850.00, 1999, 2001, 'Prata', 10000, '\xC1lcool;GNV', 'Ar-Condicionado;4 portas;Câmbio automático;', 'imagem1.jpg;imagem2.jpg;imagem3.jpg;imagem4.jpg;imagem5.jpg;'), (3, 'Ford', 'Fiesta', 21380.00, 1998, 2002, 'Preto', 23043, 'Gasolina', '', 'imagem1.jpg;imagem2.jpg;imagem3.jpg;imagem4.jpg;imagem5.jpg;');

我该怎么做?

最佳答案

\x 不是有效的转义序列。有效序列详见 http://dev.mysql.com/doc/refman/5.0/en/string-syntax.html

引用手册:

For all other escape sequences, backslash is ignored. That is, the escaped character is interpreted as if it was not escaped. For example, “\x” is just “x”.

您可以指定一个完整的十六进制字符串:

SELECT 0x61626364 -- Prints abcd

如果你想混合两种风格,你必须连接:

SELECT CONCAT('a', 0x6263, 'd') -- Prints abcd

关于PHP 和 MySQL : Store and print hex char,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3686778/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com