首页 > 数据库 > MySQL > 正文

Discuz论坛2.5 升级到PHP MySQL新版遇到的问题

2024-07-24 12:56:05
字体:
来源:转载
供稿:网友

1 中文问题,在使用mysql实例配置工具的使用,将使用的字符集设置为gbk,而不要设置为utf-8

2 mysql安装后密码无法访问问题:

mysql> set password for
    -> 'some_user'@'some_host' = old_password('newpwd');

3 php有warning

在php.ini里面找到
bug_combat_warning = 1 两行,1 改成 0

4 mysql 对sql插入实行更强的格式检查.所以如果某个列是整数,就不能使用''来插入.因此修改discuz的一个函数如下

function updatesession() {
 if(empty($globals['sessionupdated'])) {
  global $db, $sessionexists, $sessionupdated, $sid, $onlineip, $discuz_uid, $discuz_user, $timestamp, $groupid, $styleid, $invisible, $discuz_action, $fid, $tid, $onlinehold, $logincredits, $table_sessions, $table_members, $user_lastactivity, $onlinehold;

  if($sessionexists == 1) {
   $db->query("update $table_sessions set uid='$discuz_uid', username='$discuz_user', groupid='$groupid', styleid='$styleid', invisible='" . ($invisible==""?0:1) . "', action='$discuz_action', lastactivity='$timestamp', fid='" . ($fid==""?0:1) . "', tid='" . ($tid==""?0:1) . "' where sid='$sid'");
   if ($onlinehold && $user_lastactivity && $timestamp - $user_lastactivity > $onlinehold) {
    $db->query("update $table_members set lastvisit=lastactivity, lastactivity=$timestamp where uid='$discuz_uid'", 'unbuffered');
   }
  } else {
   $ips = explode('.', $onlineip);

   $db->query("delete from $table_sessions where sid='$sid' or lastactivity<($timestamp-$onlinehold) or ('$discuz_uid'<>'0' and uid='$discuz_uid') or (uid='0' and ip1='$ips[0]' and ip2='$ips[1]' and ip3='$ips[2]' and ip4='$ips[3]' and lastactivity>$timestamp-60)");
   $db->query("insert into $table_sessions (sid, ip1, ip2, ip3, ip4, uid, username, groupid, styleid, invisible, action, lastactivity, fid, tid)
    values ('$sid', '$ips[0]', '$ips[1]', '$ips[2]', '$ips[3]', '$discuz_uid', '$discuz_user', '$groupid', '$styleid', '" . ($invisible==""?0:1) . "', '$discuz_action', '$timestamp', '" . ($fid==""?0:1) . "', '" . ($tid==""?0:1) . "')");
   if($discuz_uid) {
    $db->query("update $table_members set credit=credit+".intval($logincredits).", lastip='$onlineip', lastvisit=lastactivity, lastactivity=$timestamp where uid='$discuz_uid'", 'unbuffered');
   }
  }
  $sessionupdated = 1;
 }
}

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表