Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[已解决] DV转换过程中,主题转换出现问题,某些字符过滤不当

[复制链接]
mccad 发表于 2010-11-3 11:25:53 | 显示全部楼层 |阅读模式
出错信息:
Time: 2010-11-3 2:52am
SQL: INSERT INTO discuz_temp.pre_forum_thread (tid, fid, posttableid, typeid, sortid, readperm, price, author, authorid, subject, dateline, lastpost, lastposter, views, replies, displayorder, highlight, digest, rate, special, attachment, moderated, closed, stickreply, recommends, recommend_add, recommend_sub, heats, status, isgroup) VALUES ( '2282', '4', '0', '0', '', '0', '0', 'rb', '8778', '在Delphi中调用CAD2000,只能用‘continuous线形,不能用其他线形,请问?SO02w100\', '1032018960', '1032018960', 'hhxh', '706', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1032018960', '1032018960', 'hhxh', '706', '1', '0', '0', '0', '0', '0', '0', '0'' at line 1
Errormsg.: 可能原因:1.数据超长或类型不匹配;2.数据库记录重复

红色部分应该是出错的字段数据。
我的源数据是这样:在Delphi中调用CAD2000,只能用‘continuous线形,不能用其他线形,请问?SO02w100';
而数据中,出问题是在后面的 ';符号,其中'符号会被替换成\',这并没有错,但在切短保留78个字符时,则好把'给切掉了,只剩下\号,加上数据原来本身的,又组成一个完整的\'号,造成的数据出错。

我想这种机率很小,但还是会有的。

幸福在右 发表于 2010-11-3 11:28:01 | 显示全部楼层
友情帮顶。。。
回复

使用道具 举报

wintop 发表于 2010-11-3 12:17:47 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

baxter 发表于 2010-11-3 12:58:30 | 显示全部楼层
分析的有些道理
回复

使用道具 举报

 楼主| mccad 发表于 2010-11-3 14:38:12 | 显示全部楼层
本帖最后由 mccad 于 2010-11-3 14:39 编辑

真是头大,自己改了一下,改成这样:
  1.         $subject                =        str_replace("\\'","'",$dvt['title']);
  2.         $subject                =        cutstr(htmlspecialchars(trim(@strip_tags($subject))), 78);
  3.         $subject                =        str_replace("'","\\'",$subject);
复制代码
但又出现下面的错误,另外一个位置的反斜杠号又出问题了,原标题是:
请问如何将字符串 "\"图层10\"" 变为 "图层"
  1. XConvert info: MySQL Query Error

  2. Time: 2010-11-3 6:35am
  3. SQL: INSERT INTO discuz_temp.pre_forum_thread (tid, fid, posttableid, typeid, sortid, readperm, price, author, authorid, subject, dateline, lastpost, lastposter, views, replies, displayorder, highlight, digest, rate, special, attachment, moderated, closed, stickreply, recommends, recommend_add, recommend_sub, heats, status, isgroup) VALUES ( '43738', '3', '0', '0', '', '0', '0', 'tc405003', '102301', '请问如何将字符串 \"\\\"图层10\\\"\" 变为 \"图层\', '1130777280', '1130824020', 'tc405003', '640', '7', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
  4. Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1130777280', '1130824020', 'tc405003', '640', '7', '0', '0', '0', '0', '0', '0',' at line 1
  5. Errormsg.: 可能原因:1.数据超长或类型不匹配;2.数据库记录重复
  6. Errno.: 1064
复制代码
回复

使用道具 举报

 楼主| mccad 发表于 2010-11-3 15:34:54 | 显示全部楼层
哎,还得靠自己解决:
$subject                =        rtrim($subject,'\\');
如果主题后面带有\号的,一律清掉,不管多少个带删。
可能会影响某些主题要表达的意思,但只能这样。
难啊,原来官方的转换程序也存在各种问题。考虑得不够周到。
回复

使用道具 举报

yzz001 发表于 2010-12-29 09:50:58 | 显示全部楼层
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-10-2 10:27 , Processed in 0.128649 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表