View Full Version : Country Flag Hack (Complete)

01 Sep 2001, 11:05
Version 2.0 - September 6, 2001 Released

or you can still load v1.0 below

Version 1.0 - September 1, 2001
This is the first release of the Country Hack. I've seen many people asking for this hack to be completed. I have changed and added a lot from the original Flag hack by Pingu. Thanks Pingu for the start of this hack!

This is my first hack. Everything should work fine in vBulletin v2.0.x (v2.0.3 has a note below for a different file to edit than in v2.0.1).

Version 1.0 has support for 221 countries and their corresponding flags. The country names are stored by their 2-letter ISO-3166 country codes, with the exception of Scotland which uses '01' because of no known country code (To add other countries that have no country code, use 02, 03, etc). Some countries have the same 2-letter notation because they have the same flag (e.g. many countries like France and UK have territories that use the mainland flag).

I have created large (x by 32) and small (x by 16) icons in .gif format. If you want to put the flag next to the name in the post, get the small icons. If you want to put the flag under the name or
somewhere else in the post, the large ones look better. The flag zips are in the first 2 posts below.

In Version 1.0:
- Support for 221 countries (any more? anyone?)
- Requires adult registrant to choose their country
- Allows existing users to select/change their country
in the 'Edit Profile' form
- Displays country flag on member profile page
- Use template for country list to be pulled anywhere
- Very easy to add new countries

What I'd like to add:
- A way to translate country codes to their appropriate
name to display on the profile page

I don't have a demo board setup yet and mine is still under construction. I have attached a picture:


Bane at TalkLoud has added the Country Flag hack. So I'm using his site as the demo: http://www.talkloud.net/showthread.php?threadid=203

Questions and comments...please post here. Enjoy!


01 Sep 2001, 11:06
Here are the small flag icons: http://www.thefew.com/temp/us_sm.gif

01 Sep 2001, 11:06
Here are the large flag icons: http://www.thefew.com/temp/us_lg.gif

01 Sep 2001, 12:02
Working swell :) Great job AJR!

01 Sep 2001, 16:35
Thanks It works :)
But I have a problem the Registered date isn't correct I always get

Registered: 999383174
By the way I'm using vB 2.0.3

01 Sep 2001, 17:09
Nice one, I'll try it out.

01 Sep 2001, 19:11
I am in the processing of installing your hack. I went to make a field in my database based on your instructions, Made it in user table called country type=varchar length 2 not null. when I save it the type changes to char, The only way I can get varchar to stay as the type is to change the length to 4 verus 2 is this ok?

I think it should be but I wanted to make sure.

01 Sep 2001, 20:34
Key.... do you have any hacks installed? Also do you have a link to your db to show it?

webhost... Change it back it char(2). It was originally varchar(50) because Pingu was using the country name instead of the code. I changed it in my table from 50 to 2 and didn't notice that it went from varchar to char.

The varchar type saves space in your database, but it doesn't make a difference with less than 4 characters. If you had char(250) instead of varchar(250), you would waste A LOT of space if that field only had something like "This is a test". It's only 14 characters but would be forced to use 250 characters with char(250)! Sorry for the MySQL tutuorial :) Actually I noticed that one or 2 of the tables in vbulletin (can't remember which ones) use char() instead of varchar() and their size can get large rather quickly. If you use phpMyAdmin, go in and check the size of your tables vs the number of entries. You'll know which ones are using char() to store the data by their size/entry ratio. USE AT OWN RISK: You may be able to speed up your forums by changing all the char() to varchar(). It will reduce the size of the .ISD and .ISM file for quicker add/replace/searches. It works on my forum fine, but do this at your own risk! Backup the tables you are going to make the changes in first!

01 Sep 2001, 20:38
I ended up setting varchar to 4. Hack is installed and running great.
Thanks for the great work.


01 Sep 2001, 21:10
Yes MSN Hack
No coz I'm just testing it in my Personal PC.

01 Sep 2001, 23:35
1 - Add to database-Table user, field named: country
( country varchar(2) NOT NULL )

Before I screw up my database

should the part I insert into "Run SQL query/queries on database" textbox in phpmyadin is

Table user, field named: country
( country varchar(2) NOT NULL )

or do I use the

- Add to database-Table user, field named: country
( country varchar(2) NOT NULL )

when I insert it.

Thanks for the help!

01 Sep 2001, 23:39
In phpMyAdmin, you can run this query:

ALTER TABLE user ADD country CHAR (2) not null

01 Sep 2001, 23:43
4 mins on that reply.. not bad

02 Sep 2001, 01:39
Parse error: parse error in /home/dlrarmy/public_html/forums/register.php on line 93

That was probably my fault... I don't know. I thought I did it right.

Anyways besides in register.php I have the hack installed and it looks really good!


02 Sep 2001, 01:43
I wonder if the parse error was because of my stars hack?

02 Sep 2001, 01:45
Looks good Sarge! Got a few hacks installed do ya :). For your register error, make sure your register.php looks like this around the line 90's (I put in some code above and below the hack):

//MaxPosts by User
$optionArray = explode(",", $usermaxposts);
while (list($key, $val) = each($optionArray))
eval ("\$maxpostsoptions .= \"".gettemplate("modifyoptions_maxposts")."\";");
$postsdefaultselected = "selected";
// Country Hack
eval("\$countrytext.= \"".gettemplate("modifyprofile_country")."\";");
// Country Hack End
// Referrer

Just make sure you put the eval line for the country hack in the right place.

02 Sep 2001, 10:10
<!-- Database error in vBulletin: Invalid SQL: INSERT INTO user (userid,username,password,email,parentemail,coppauser,homepage,icq,aim,yahoo,sig nature,adminemail,showemail,invisible,usertitle,joindate,cookieuser,daysprune,la stvisit,lastactivity,usergroupid,timezoneoffset,emailnotification,receivepm,emai lonpm,options,birthday,maxposts,startofweek,ipaddress,pmpopup,referrerid,nosessi onhash,country) VALUES (NULL,'Kinta Kunte','eeeeee','e@blackman.com','','0','http://www.dlrarmy.com','','','','','1','1','0','Recruit','999421680','1','-1','999421680','999421680','3','0','1','1','1','15','1966-3-4','-1','1','','1','0','1','','','pg')
mysql error: Column count doesn't match value count at row 1
mysql error number: 1136
Date: Sunday 02nd of September 2001 05:08:00 AM
Script: /forums/register.php
Referer: http://www.dlrarmy.com/forums/register.php

I changed it and this is what I got..

Want me to send you the register file so you can look it over? I know this has to do because I have hacked the sheettz out of my forums.

My users are digging this hack by the way

02 Sep 2001, 10:29
Just read what the error is telling you... field mismatch - means either there are too many column names, or too many values. After matching them up, you have too many values trying to be inserted into the database.

It looks like you have the stars hack installed because the extra spaces are the ,'','', below from the error message:


If you have the stars hack installed, make sure on the $DB_site->query line just before VALUES you have the following:


Currently you only have:


If you don't get what I mean let me know.

02 Sep 2001, 11:10
nice hack

02 Sep 2001, 18:25
Originally posted by AJR
Just read what the error is telling you... field mismatch - means either there are too many column names, or too many values. After matching them up, you have too many values trying to be inserted into the database.

It looks like you have the stars hack installed because the extra .

I just emailed you bro.
Thnks for doing this hack i have been waiting a long time for this

02 Sep 2001, 22:12
Great hack, wandering if you make a addon for it.
I noticed today that when viewing my profile via the admin control panel the option for the flags does not show up along with the other profile fields. Can you add this option where it will show up in the control panel?

02 Sep 2001, 23:59
Thanks dude
That worked!

Hey is there anyway we could add alt tags to the images?

03 Sep 2001, 23:22
i`ve written a small addon, which allows to work with flags in cp

here is a demo ;)

Instructions are here:

06 Sep 2001, 10:52
I have released v2.0 of the Country Flag Hack. There are some great additions/updates to the new version. You can find it here: http://vbulletin.com/forum/showthread.php?s=&threadid=27485

06 Sep 2001, 13:22
tnx for remebering me ;)

06 Sep 2001, 15:16
thanks for spelling my name right :p

06 Sep 2001, 18:13
Bane...where the heck were you last night?? I wanted you to create an install script for v2.0! Waited up until about 4am!! Everyone, thank Bane for not being around last night and creating an install script :rolleyes:

And of course I'm going to spell your name right :) Only idiots spell it Bain :D

Stasik...all I need is the right direction sometimes, and you led me down the path of how to edit the Admin CP with your Add-on! Thanks!

06 Sep 2001, 18:24
no problem ;)

06 Sep 2001, 21:15
Doh, I was at war!!

Tony DiMera
27 Jan 2003, 00:09
Cool hack thanks,