- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
免责声明
在尝试结束这个问题之前,请理解我已经将它发布在 wordpress.se.com 上,甚至提供了赏金但没有答案。这让我相信问题可能与 WordPress 本身无关,而是一些我尚不了解的 php/mysql 怪癖。我希望我在下面为 php/mysql 专家提供了足够的信息,让我知道可能出了什么问题。
我遇到的问题是更新语句
UPDATE
`s_6_posts`
SET
`post_author` = 9,
`post_date` = '2012-04-11 20:40:05',
`post_date_gmt` = '2012-04-11 20:40:05',
`post_content` = '\n\n\n<div class=\"WordSection1\">\n\n<p class=\"MsoNormal\" style=\"margin-bottom:0in;margin-bottom:.0001pt;line-height:normal\"><b><span style=\'font-size:9.0pt;font-family:\"ArialNarrow\",\"sans-serif\";color:red\'>This is a new document</span></b></p>\n\n<p class=\"MsoNormal\" style=\"margin-bottom:0in;margin-bottom:.0001pt;line-height:normal\"><b><span style=\'font-size:9.0pt;font-family:\"ArialNarrow\",\"sans-serif\";color:red\'> </span></b></p>\n\n<p class=\"MsoNormal\" style=\"margin-bottom:0in;margin-bottom:.0001pt;line-height:normal\"><b><span style=\'font-size:9.0pt;font-family:\"ArialNarrow\",\"sans-serif\";color:red\'>Test Test Test</span></b></p>\n\n</div>\n\n\n',
`post_content_filtered` = '',
`post_title` = '',
`post_excerpt` = '',
`post_status` = 'draft',
`post_type` = 'post',
`comment_status` = 'open',
`ping_status` = 'open',
`post_password` = '',
`post_name` = '',
`to_ping` = '',
`pinged` = '',
`post_modified` = '2012-04-11 20:40:05',
`post_modified_gmt` = '2012-04-11 20:40:05',
`post_parent` = 0,
`menu_order` = 0,
`guid` = 'https://qa.citivelocity.com/cvauthor/equitywire/?p=230'
WHERE
`ID` = 230
在 php(WordPress 代码库)中执行时被切断。 post_content 字段在数据库中的结果是
<div class="WordSection1">
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:normal"><b><span style='font-size:9.0pt;font-family:"ArialNarrow","sans-serif";color:red'>This is a new document</span></b></p>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:normal"><b><span style='font-size:9.0pt;font-family:"ArialNarrow","sans-serif";color:red'>
问题
这里发生的事情是在
<span style='font-size:9.0pt;font-family:"ArialNarrow","sans-serif";
color:red'> </span>
block ,<span>
之间的空格之后的所有内容标签被切断。我已经能够与其他包含空间的数据一致地重现此问题。这似乎不是字段的大小限制,因为无论数据长度如何,截止总是发生在空格处。
这个 SQL 语句是在 WordPress 调试日志中输出的,我有充分的理由相信它实际上是正在执行的语句。我通过 MySQL 客户端 (Aqua Data Studio) 运行相同的语句,但没有发生中断。
我在 CentOs 上运行 Mysql 5.0.77 和 php 5.3。表是 MyISAM,排序规则是 utf8_general_ci。
发布表架构:
CREATE TABLE `s_posts` (
`ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`post_author` bigint(20) unsigned NOT NULL DEFAULT '0',
`post_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_content` longtext NOT NULL,
`post_title` text NOT NULL,
`post_excerpt` text NOT NULL,
`post_status` varchar(20) NOT NULL DEFAULT 'publish',
`comment_status` varchar(20) NOT NULL DEFAULT 'open',
`ping_status` varchar(20) NOT NULL DEFAULT 'open',
`post_password` varchar(20) NOT NULL DEFAULT '',
`post_name` varchar(200) NOT NULL DEFAULT '',
`to_ping` text NOT NULL,
`pinged` text NOT NULL,
`post_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_modified_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_content_filtered` text NOT NULL,
`post_parent` bigint(20) unsigned NOT NULL DEFAULT '0',
`guid` varchar(255) NOT NULL DEFAULT '',
`menu_order` int(11) NOT NULL DEFAULT '0',
`post_type` varchar(20) NOT NULL DEFAULT 'post',
`post_mime_type` varchar(100) NOT NULL DEFAULT '',
`comment_count` bigint(20) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`),
KEY `post_name` (`post_name`),
KEY `type_status_date` (`post_type`,`post_status`,`post_date`,`ID`),
KEY `post_parent` (`post_parent`),
KEY `post_author` (`post_author`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
最佳答案
您没有发布处理数据库交互的代码(如何构建和执行查询),但如果您准备
字符串,您的数据应该按预期完整插入/更新。
我通过 PDO::prepare
运行字符串并得到:
6774 Query update fulltext_test set post_content = '\\n\\n\\n<div class=\\\"WordSection1\\\">\\n\\n<p class=\\\"MsoNormal\\\" style=\\\"margin-bottom:0in;margin-bottom:.0001pt;line-height:normal\\\"><b><span style=\'font-size:9.0pt;font-family:\\\"ArialNarrow\\\",\\\"sans-serif\\\";color:red\'>This is a new document</span></b></p>\\n\\n<p class=\\\"MsoNormal\\\" style=\\\"margin-bottom:0in;margin-bottom:.0001pt;line-height:normal\\\"><b><span style=\'font-size:9.0pt;font-family:\\\"ArialNarrow\\\",\\\"sans-serif\\\";color:red\'> </span></b></p>\\n\\n<p class=\\\"MsoNormal\\\" style=\\\"margin-bottom:0in;margin-bottom:.0001pt;line-height:normal\\\"><b><span style=\'font-size:9.0pt;font-family:\\\"ArialNarrow\\\",\\\"sans-serif\\\";color:red\'>Test Test Test</span></b></p>\\n\\n</div>\\n\\n\\n' WHERE id = 1 limit 1
注意转义字符的所有转义。验证数据插入mysql成功:
mysql> select * from fulltext_test\G
*************************** 1. row ***************************
id: 1
comment: this is a test comment right here 123453432
trimmed_comments: this
post_content: \n\n\n<div class=\"WordSection1\">\n\n<p class=\"MsoNormal\" style=\"margin-bottom:0in;margin-bottom:.0001pt;line-height:normal\"><b><span style='font-size:9.0pt;font-family:\"ArialNarrow\",\"sans-serif\";color:red'>This is a new document</span></b></p>\n\n<p class=\"MsoNormal\" style=\"margin-bottom:0in;margin-bottom:.0001pt;line-height:normal\"><b><span style='font-size:9.0pt;font-family:\"ArialNarrow\",\"sans-serif\";color:red'> </span></b></p>\n\n<p class=\"MsoNormal\" style=\"margin-bottom:0in;margin-bottom:.0001pt;line-height:normal\"><b><span style='font-size:9.0pt;font-family:\"ArialNarrow\",\"sans-serif\";color:red'>Test Test Test</span></b></p>\n\n</div>\n\n\n
以及代码片段:
<?php
$dsn = 'mysql:dbname=zzz_test;host=127.0.0.1';
try {
$dbo = new PDO($dsn, 'user', 'pass');
} catch (Exception $e) {
var_dump($e->getMessage());
}
$string = '\n\n\n<div class=\"WordSection1\">\n\n<p class=\"MsoNormal\" style=\"margin-bottom:0in;margin-bottom:.0001pt;line-height:normal\"><b><span style=\'font-size:9.0pt;font-family:\"ArialNarrow\",\"sans-serif\";color:red\'>This is a new document</span></b></p>\n\n<p class=\"MsoNormal\" style=\"margin-bottom:0in;margin-bottom:.0001pt;line-height:normal\"><b><span style=\'font-size:9.0pt;font-family:\"ArialNarrow\",\"sans-serif\";color:red\'> </span></b></p>\n\n<p class=\"MsoNormal\" style=\"margin-bottom:0in;margin-bottom:.0001pt;line-height:normal\"><b><span style=\'font-size:9.0pt;font-family:\"ArialNarrow\",\"sans-serif\";color:red\'>Test Test Test</span></b></p>\n\n</div>\n\n\n';
$sql = 'update fulltext_test set post_content = :postContent WHERE id = 1 limit 1;';
$stmt = $dbo->prepare($sql);
$stmt->bindValue(':postContent', $string);
$stmt->execute();
所以,在执行查询之前尝试对字符串进行转义,你应该是黄金。为了记录,一切都是UTF-8;连接、整理等
关于php - MySQL更新语句被切断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10403530/
创建一个“海盗对话”,可以选择左手或右手。我希望它对“左”和“右”的不同拼写做出积极的回答(正如您将在代码中看到的那样),但是,当我为所有非“右”或“左”的输入添加最终的“else”代码时,它给了我一
With 语句 对一个对象执行一系列的语句。 With object statements End With 参数 object 必需的部分
While...Wend 语句 当指定的条件为 True 时,执行一系列的语句。 While condition  ; Version [stat
所以我正在处理的代码有一个小问题。 while True: r = input("Line: ") n = r.split() if r == " ":
我有一个对象数组: var contacts = [ { "firstName": "Akira", "lastName": "Laine", "number"
int main() { int f=fun(); ... } int fun() { return 1; return 2; } 在上面的程序中,当从main函数中调用一个
我的项目中有很多 if 语句、嵌套 if 语句和 if-else 语句,我正在考虑将它们更改为 switch 语句。其中一些将具有嵌套的 switch 语句。我知道就编译而言,switch 语句通常更
Rem 语句 包含程序中的解释性注释。 Rem comment 或 ' comment comment 参数是需要包含的注释文本。在 Rem 关键字和 comment 之间应有一个空格。
ReDim 语句 在过程级中声明动态数组变量并分配或重新分配存储空间。 ReDim [Preserve] varname(subscripts) [, varname(subscripts)]
Randomize 语句 初始化随机数生成器。 Randomize [number] number 参数可以是任何有效的数值表达式。 说明 Randomize 使用 number 参数初始
Public 语句 定义公有变量并分配存储空间。在 Class 块中定义私有变量。 Public varname[([subscripts])][, varname[([subscripts])
Sub 语句 声明 Sub 过程的名称、参数以及构成其主体的代码。 [Public [Default]| Private] Sub name [( arglist )]
Set 语句 将对象引用赋给一个variable或property,或者将对象引用与事件关联。 Set objectvar = {objectexpression | New classname
我有这个代码块,有时第一个 if 语句先运行,有时第二个 if 语句先运行。我不确定为什么会这样,因为我认为 javascript 是同步的。 for (let i = 0; i < dataObje
这是一个 javascript 代码,我想把它写成这样:如果此人回答是,则回复“那很酷”,如果此人回答否,则回复“我会让你开心”,如果此人回答的问题包含"is"或“否”,请说“仅键入”是或否,没有任何
这是我的任务,我尝试仅使用简短的 if 语句来完成此任务,我得到的唯一错误是使用“(0.5<=ratio<2 )”,除此之外,构造正确吗? Scanner scn = new Scanner(
有没有办法在 select 语句中使用 if 语句? 我不能在这个中使用 Case 语句。实际上我正在使用 iReport 并且我有一个参数。我想要做的是,如果用户没有输入某个参数,它将选择所有实例。
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicate: If vs. Switch Speed 我将以 C++ 为例,但我要问的问题不是针对特定语言的。我的意思是一
Property Set 语句 在 Class 块中,声明名称、参数和代码,这些构成了将引用设置到对象的 Property 过程的主体。 [Public | Private] Pro
Property Let 语句 在 Class 块中,声明名称、参数和代码等,它们构成了赋值(设置)的 Property 过程的主体。 [Public | Private] Prop
我是一名优秀的程序员,十分优秀!