首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在我的一些更新中PHPMyAdmin导入截断文本字段?

问为什么在我的一些更新中PHPMyAdmin导入截断文本字段?
EN

Stack Overflow用户
提问于 2012-07-13 19:28:01
回答 2查看 2.4K关注 0票数 0

我的数据库中有一些不可靠的字符,这要归功于一个编码不当的过滤器脚本(当然,这是由您真正创建的!)

我通过将数据从PHPMyAdmin导出为一个SQL文件来修正数据,然后艰苦地CTRL+H搜索&将不正确的字符替换为正确的字符。然后,我使用PHPMyAdmin重新导入SQL文件(嗯,三个单独的文件)。

这对大多数数据都很有效,但在一些帖子上,它们似乎完全被切断了。

代码语言:javascript
复制
meta_id     post_id     meta_key            meta_value
162227      264847      water_chemistry     <strong>Temperature</strong>:
162228      264847      diet                <em>Homaloptera</em>
162229      264847      behaviour           <p>Not an aggressive fish although its particular requirements limit the choice of suitable tankmates.
162218      264847      maintenance         <p>Most importantly the water must be clean and well-oxygenated so we suggest the use of an over-sized

例如,本种概况 (上面的文本)应该已经应用了以下UPDATE语句:

代码语言:javascript
复制
UPDATE `wp_postmeta` SET `meta_id` = 162228,`post_id` = 264847,`meta_key` = 'diet',`meta_value` = '<em>Homaloptera</em> spp. are specialised grazers feeding on <a href="/glossary/b/biofilm" rel="/glossary/b/biofilm?hover=true">biofilm</a>, small crustaceans, insect <a href="/glossary/l/larvae" rel="/glossary/l/larvae?hover=true">larvae</a> and other invertebrates. In captivity some sinking dried foods may be accepted but regular meals of live or frozen <em><a href="/glossary/D/Daphnia" rel="/glossary/D/Daphnia?hover=true">Daphnia</a></em>, <em><a href="/glossary/A/Artemia" rel="/glossary/A/Artemia?hover=true">Artemia</a></em>, <a href="/glossary/b/bloodworm" rel="/glossary/b/bloodworm?hover=true">bloodworm</a>, etc. are essential for the maintenance of good health, and it''s highly preferable if the <a href="/glossary/t/tank" rel="/glossary/t/tank?hover=true">tank</a> contains rock and other solid surfaces with growths of <a href="/glossary/a/algae" rel="/glossary/a/algae?hover=true">algae</a> and other <a href="/glossary/a/aufwuchs" rel="/glossary/a/aufwuchs?hover=true">aufwuchs</a>.\r\n\r\nBalitorids are often seen on sale in an emaciated state which can be difficult to correct. A good dealer will have done something about this prior to sale but if you decide to take a chance with severely weakened specimens they''ll initially require a continual, easily-obtainable source of suitable foods in the absence of competitors if they''re to recover.' WHERE `wp_postmeta`.`meta_id` = 162228;

UPDATE `wp_postmeta` SET `meta_id` = 162227,`post_id` = 264847,`meta_key` = 'water_chemistry',`meta_value` = '<strong>Temperature</strong>: [temp]\r\n\r\n<strong>pH</strong>: [pH]\r\n\r\n<strong>Hardness</strong>: [hardness]' WHERE `wp_postmeta`.`meta_id` = 162227;

UPDATE `wp_postmeta` SET `meta_id` = 162229,`post_id` = 264847,`meta_key` = 'behaviour',`meta_value` = '<p>Not an aggressive fish although its particular requirements limit the choice of suitable tankmates. <a href="/glossary/s/species" rel="/glossary/s/species?hover=true">Species</a> inhabiting similar environments include <em>Barilius</em>, <em>Discherodontus</em>, <em>Garra</em>, larger <em>Devario</em>, some <em>Rasbora</em>, gobies of the <a href="/glossary/g/genera" rel="/glossary/g/genera?hover=true">genera</a> <em>Rhinogobius</em>, <em>Sicyopterus</em> and <em>Stiphodon</em> plus <em>Glyptothorax</em>, <em>Akysis</em> and <em>Oreoglanis</em> spp. catfishes.\r\n\r\nMany loaches from the <a href="/glossary/f/family" rel="/glossary/f/family?hover=true">family</a> Nemacheilidae and most from Balitoridae are also suitable although harmless squabbles may occur with the latter group in particular. Research your choices before purchase to be sure.\r\n\r\nIt''s found living in aggregations in nature so buy six or more to see it at its best as when kept singly or in pairs/trios it''s less bold. The interaction between individuals is also interesting to watch and a group will typically arrange themselves close to one another facing directly into the water flow at certain times of day.</p>' WHERE `wp_postmeta`.`meta_id` = 162229;

UPDATE `wp_postmeta` SET `meta_id` = 162218,`post_id` = 264847,`meta_key` = 'maintenance',`meta_value` = '<p>Most importantly the water must be clean and well-oxygenated so we suggest the use of an over-sized <a href="/glossary/f/filter" rel="/glossary/f/filter?hover=true">filter</a> as a minimum requirement. Turnover should ideally be 10-15 times per hour so additional powerheads, airstones, etc., should be employed to achieve the desired flow and <a href="/glossary/o/oxygenation" rel="/glossary/o/oxygenation?hover=true">oxygenation</a> if necessary.\r\n\r\n<a href="/glossary/b/base" rel="/glossary/b/base?hover=true">Base</a> <a href="/glossary/s/substrate" rel="/glossary/s/substrate?hover=true">substrate</a> can either be of <a href="/glossary/g/gravel" rel="/glossary/g/gravel?hover=true">gravel</a>, <a href="/glossary/s/sand" rel="/glossary/s/sand?hover=true">sand</a> or a mixture of both to which should be added a layer of water-worn rocks and pebbles of varying sizes. Driftwood roots and branches are also suitable and although rarely a feature of the natural <a href="/glossary/h/habitat" rel="/glossary/h/habitat?hover=true">habitat</a> <a href="/glossary/a/aquatic" rel="/glossary/a/aquatic?hover=true">aquatic</a> plants from adaptable genera such as <em>Microsorum</em>, <em>Crinum</em> and <em>Anubias</em> spp. can also be added. The latter are particularly useful as <em>Homaloptera</em> spp. appear to enjoy resting on their leaves.\r\n\r\nSince it needs stable water conditions and feeds on <a href="/glossary/b/biofilm" rel="/glossary/b/biofilm?hover=true">biofilm</a> this species should never be added to a biologically immature set-up, and a tightly-fitting cover is necessary since it can literally climb glass. While regular partial water changes are essential aufwuchs can be allowed to grow on all surfaces except perhaps the viewing pane.</p>' WHERE `wp_postmeta`.`meta_id` = 162218;

然而,由于某种原因,正如您可以看到的物种配置文件(而且它在数据库中是完全相同的),大部分的文本是缺失的。

有什么原因吗?导入根本不会引发任何错误。

编辑

我尝试将\r\n字符替换为###,以查看数据导入是否正确--它没有。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-07-14 00:13:13

最后,这是一个编码问题。当我最初将我的SQL数据分割成两个单独的文件时,新文件默认编码为ANSI,其中原始文件(和我的数据库是UTF-8)。

当将编码改为UTF-8时,我看到了大量奇怪的小字符,我的文本编辑器无法搜索和替换这些字符。

我将编码设置为ANSI,使用UTF-8创建了一个新的文本文档,并简单地将信息从ANSI文档复制到新的UTF-8文件。

所有这些都是在Notepad++中完成的。

问题解决了-7小时的诊断问题;不到5秒的修复。

票数 2
EN

Stack Overflow用户

发布于 2012-07-13 20:41:21

如果您正在使用PHP,请使用mysql_real_escape_string():这就是正在发生的事情

代码语言:javascript
复制
mysql> select "<strong>Temperature</strong>: [temp]\r\n\r\n<strong>pH</strong>:";
+--------------------------------------------------------------+
| <strong>Temperature</strong>: [temp]

<strong>pH</strong>: |
+--------------------------------------------------------------+
| <strong>Temperature</strong>: [temp]

<strong>pH</strong>: |
+--------------------------------------------------------------+
1 row in set (0.00 sec)

因此,使用php函数来准确地存储数据。

http://dev.mysql.com/doc/refman/5.1/en/mysql-real-escape-string.html

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11477084

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档