Fixing Discuz! 3.1 Database Error After Enabling QQ Connect: (1054) Unknown column 'conuintoken' in 'field list'

Yesterday I tried the latest Discuz! 3.1. After enabling QQ Connect, the whole forum threw errors showing “Discuz! Database Error”. Let’s look into it. First the error:

Discuz database error

It reported: (1054) Unknown column conuintoken in field list

UPDATE common_member_connect SET “conuintoken”=“4866612C1C0E76EF744AD92AB5F7F059” , conopenid=“6114C6C27E15656939C3ABBEE70E6E37” , conisfeed=“1” WHERE uid=“1”

What this means: when you log in with QQ, your account info is written into the table common_member_connect. This statement uses the field conuintoken, but the table common_member_connect doesn’t have it, hence the error — so Discuz throws it at us. Actually, anyone with a bit of database knowledge can fix this bug themselves: the table needs the conuintoken field but doesn’t have it, so just add it. Because many webmasters aren’t technical, let’s not go into phpMyAdmin — you can run SQL right inside Discuz.

  1. Edit config/config_global.php and find the following code, change 0 to 1 to enable direct SQL execution in the admin panel:

[php]$_config[“admincp”][“runquery”] = “0”;[/php]

  1. In the admin panel — Founder — Database — Upgrade, paste the following code and submit:

[code lang=“sql”] alter table pre_common_member_connect add conuintoken char(32) not null; alter table pre_common_connect_guest add conuintoken char(32) not null; [/code]

If your table prefix isn’t the default “pre”, change it to your corresponding prefix. -----------------------------------------------------------------------------

Finally, for those who know databases, here’s the fix — I prefer editing the database directly in phpMyAdmin rather than in Discuz. Go to phpMyAdmin, find your database, find the table pre_common_member_connect, click SQL, and run:

[code lang=“sql”]alter table pre_common_member_connect add conuintoken char(32) not null;[/code]

If running globally, add the database name — e.g. if the database is named “db”, then pre_common_member_connect should be db.pre_common_member_connect. Watch your table prefix; if it isn’t the default “pre”, change it accordingly!

Once that’s done, the table pre_common_member_connect has the conuintoken field. Check whether Discuz is fine now?