I have installed register.country as per the documentation.
Everything installs without an error.
When I go to admin/settings/register_country I get the following error message.

user warning: Table 'shooter.drupal_iso3166' doesn't exist query: SELECT country_code2 AS code, country_name AS name FROM drupal_iso3166 in /var/www/sites/corpcomp/shooter.co.nz/subdomains/www/html/sites/all/modules/register_country/register_country.module on line 73.

No countries are listed at all.

I have looked at the datadase only to find that table drupal_iso3166 doesn't exist. Tables drupal_ip2cc and drupal_countries_api_countries do exist.

Thoughts, comment, suggestions would be most helpful.

Regards

Fred

Comments

vishun’s picture

hey there,

i believe i have fixed the issue, or at least, resolved these errors... the problem is that apparently both the table name and the column names changed in regards to the query being made to list the available countries. i had the initial issue of not having countries_api installed (which it should have a proper dependency flag set for but doesnt appear to) but so heres how you can fix those errors.

in register_country.module -- line 73 -- change it to:
$results = db_query("SELECT iso2 AS code, printable_name AS name FROM {countries_api_countries}");

country_code2 has become iso2, country_name has become printable_name, and iso3166 has become countries_api_countries

hope that helps, and i hope there isnt any other issues ;) this module would be useful for us, but if there are other issues we're likely to fix them because this is kind necessary for what we're doing

vishun’s picture

from what i can tell, it appears to work exactly as expected now... previously i was getting the denial page while trying to register because the list was broken and essentially nothing had been selected, so after i selected united states only (as thats our intentions) sure enough, the registration page started working. so it appears to be A-Ok :)

JCOFFEY’s picture

Status: Active » Closed (fixed)

This fixed my issue! Thanks!

nancydru’s picture

Assigned: Unassigned » nancydru
Status: Closed (fixed) » Active

Let's leave this active until I get a chance to do a formal fix.

vishun’s picture

good call, i should have provided a patch because now i barely even remember this issue. i probably could still roll a patch if you prefer

nealeyoung’s picture

Notice to the maintainer and anyone trying this patch...

The fix in comment #1 worked for me, but only AFTER I had also installed and enabled an additional module --- the countries_api ("Country codes API") module (in addition to ip2cc). The country codes API module apparently creates the {countries_api_countries} table.

freestone’s picture

Yes you have to install the Country Codes API first and make the changes in #1.

If the code returned is null I assume it will not be int he array so I changed all this:

if ($country->country_code2) {
// If it's not an allowed country code, go to the error page.
if (!in_array($country->country_code2, $register_country_settings['countries'])) {
drupal_goto($register_country_settings['error_page']);
}
}
else {
drupal_set_message("Your IP address was not found in our country look up table.");
drupal_goto($register_country_settings['error_page']);
}

To this:

if (!in_array($country, $register_country_settings['countries'])) {
drupal_goto($register_country_settings['error_page']);
}

and this in worked for me. The value is returned to $country no $country->country_code2 and I am not sure what that is.

In addition I like the module http://drupal.org/project/ip2country better than ip2cc so I change the info file for this module to use that module as a dependency and then you also need to change this main module ...Change this line

$country = ip2cc_get_country(ip_address());

to instead call the ip2country module using this line

$country = ip2country_get_country(ip_address());

I like the IPeCountry module better because it auto updates.

Cheers.... hope this helps .... I spend hours getting this to work.