Discuz! X论坛上传附件到100%自动取消上传的缘由及解决方案

最近接到一些站长的反馈,说论坛上传附件,到100%的时候本身取消上传了。经查是附件索引表pre_forum_p_w_upload表的aid字段自增值出现了问题,致使程序逻辑返回的aid值实际为一个MySQL 1062 报错:
来自网页的消息
—————————
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”><html><head> <title>10.144.49.99 – Database Error</title> <meta http-equiv=”Content-Type” content=”text/html; charset=gbk” /> <meta name=”ROBOTS” content=”NOINDEX,NOFOLLOW,NOARCHIVE” /> <style type=”text/css”> <!– body { background-color: white; color: black; font: 9pt/11pt verdana, arial, sans-serif;} #container { width: 1024px; } #message { width: 1024px; color: black; } .red {color: red;} a:link { font: 9pt/11pt verdana, arial, sans-serif; color: red; } a:visited { font: 9pt/11pt verdana, arial, sans-serif; color: #4e4e4e; } h1 { color: #FF0000; font: 18pt “Verdana”; margin-bottom: 0.5em;} .bg1{ background-color: #FFFFCC;} .bg2{ background-color: #EEEEEE;} .table {background: #AAAAAA; font: 11pt Menlo,Consolas,”Lucida Console”} .info { background: none repeat scroll 0 0 #F3F3F3; border: 0px solid #aaaaaa; border-radius: 10px 10px 10px 10px; color: #000000; font-size: 11pt; line-height: 160%; margin-bottom: 1em; padding: 1em; } .help { background: #F3F3F3; border-radius: 10px 10px 10px 10px; font: 12px verdana, arial, sans-serif; text-align: center; line-height: 160%; padding: 1em; } .sql { background: none repeat scroll 0 0 #FFFFCC; border: 1px solid #aaaaaa; color: #000000; font: arial, sans-serif; font-size: 9pt; line-height: 160%; margin-top: 1em; padding: 4px; } –> </style></head><body><div id=”container”><h1>Discuz! Database Error</h1><div class=’info’>(1062) Duplicate entry ’107697′ for key 1<div class=”sql”>INSERT INTO forum_p_w_upload SET `tid`=’0′ , `pid`=’0′ , `uid`=’1′ , `tableid`=’127′</div></div><div class=”info”><p><strong>PHP Debug</strong></p><table cellpadding=”5″ cellspacing=”1″ width=”100%” class=”table”><tr class=”…
—————————
肯定
咱们看到其实是一段html代码(其实若是站长关注后台的运行记录,也会有这个报错的,只不过我是先排查代码,才发现的),也就是Discuz! X的MySQL报错信息页面,这里最重要的信息就是MySQL的报错了,Discuz! Database Erro (1062) Duplicate entry ’107697′ for key 1 INSERT INTO forum_p_w_upload SET `tid`=’0′ , `pid`=’0′ , `uid`=’1′ , `tableid`=’127′ 。知道了aid 1062 报错,即插入了重复的值,那么就好办了,去pre_forum_p_w_upload 修改自增值就能够了,自增值修改为什么呢,固然要看一下aid当前的最大值多少,而后加1就是要修改的自增值了。能够在MySQL命令行执行:alter table pre_forum_p_w_upload auto_increment = aid最大值+1 ,若是有phpMyAdmin的话,更好操做了了,这里就很少说了。至于为何自增值会出问题,还没详细研究,不过收集的几个状况包括重启服务器,数据库迁移等操做。php


源于青互联虚拟主机博客http://www.qing.escss