Could someone please check, and correct these tables for me?

Hello

I am adding 2 new tables to my Install.php scipt

could someone please check, and correct these tables for me ?

$db_desc = “Creating <b>ip2nation</b> table”;
$db_query = “CREATE TABLE " . DB_PREFIX . "ip2nation (
ip int(11) unsigned NOT NULL default ‘0’,
country varchar(2) NOT NULL default ‘’,
blocked tinyint(4) NOT NULL default ‘0’,
KEY ip (ip);”;

$db_desc = “Creating <b>ip2nationCountries</b> table”;
$db_query = " CREATE TABLE " . DB_PREFIX . "ip2nationCountries (
code varchar(4) NOT NULL default ‘’,
country varchar(255) NOT NULL default ‘’,
lat float NOT NULL default '0', lon float NOT NULL default ‘0’,
blocked tinyint(4) NOT NULL default ‘0’,
PRIMARY KEY (code),
KEY code (code);";

Hi,
I’m not sure what the problem is, i noticed that you put string value (default ‘0’) to columns for numbers, also, some quote ` not closed.So, try:


$db_desc[] = "Creating <b>ip2nation</b> table";
$db_query[] = "CREATE TABLE `" . DB_PREFIX . "ip2nation` (
`ip` int(11) unsigned NOT NULL default 0,
`country` varchar(2) NOT NULL default '',
`blocked` tinyint(4) NOT NULL default 0,
KEY `ip` (`ip`)";

$db_desc[] = "Creating <b>ip2nationCountries</b> table";
$db_query[] = " CREATE TABLE `" . DB_PREFIX . "ip2nationCountries` (
`code` varchar(4) NOT NULL default '',
`country` varchar(255) NOT NULL default '',
`lat` float NOT NULL default 0,
`lon` float NOT NULL default 0,
`blocked` tinyint(4) NOT NULL default 0,
PRIMARY KEY (`code`),
KEY `code` (`code`)";

Thank you Marplo :slight_smile: Fantastic

I was working from unclear info, and copying what I saw in the already existing code:

NOT NULL default ‘0’, so I did the same :slight_smile:

I want to now populate each table with info like:

INSERT INTO ip2nation (ip, country) VALUES(184549375, ‘us’);
INSERT INTO ip2nation (ip, country) VALUES(3332726783, ‘ca’);

INSERT INTO ip2nationCountries (code, country, lat, lon) VALUES(‘ad’, ‘Andorra’, 42.3, 1.3);
INSERT INTO ip2nationCountries (code, country, lat, lon) VALUES(‘ae’, ‘United Arab Emirates’, 24, 54);

Is this code below correct to populate the “ip2nation” table?

$db_desc = “Populating <b>ip2nation</b> table”;
$db_query = "INSERT INTO " . DB_PREFIX . "ip2nation VALUES
(184549375, ‘us’),
(3332726783, ‘ca’),
and more
and another
and more … :slight_smile:

Hi,
The code seems correct, but you’ll know better if you use it :).

Hello

I get a SQL Error for the ($db_desc = “Creating <b>ip2nation</b> table”:wink: below the dotted line,

all help appreciated :slight_smile:

Mysql Error Output: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 5
SQL Query: CREATE TABLE ip2nation ( ip int(11) unsigned NOT NULL default 0, country varchar(2) NOT NULL default ‘’, blocked tinyint(4) NOT NULL default 0, KEY ip (ip)

$db_desc = “Creating <b>ip2nation</b> table”;
$db_query = “CREATE TABLE " . DB_PREFIX . "ip2nation (
ip int(11) unsigned NOT NULL default ‘0’,
country varchar(2) NOT NULL default ‘’,
blocked tinyint(4) NOT NULL default ‘0’,
KEY ip (ip);”;

Hi,
It is missing the closing “)” , try this:

$db_desc[] = "Creating &lt;b&gt;ip2nation&lt;/b&gt; table";
$db_query[] = "CREATE TABLE `" . DB_PREFIX . "ip2nation` (
`ip` int(11) unsigned NOT NULL default '0',
`country` varchar(2) NOT NULL default '',
`blocked` tinyint(4) NOT NULL default '0',
KEY `ip` (`ip`))";

Thank you MarPlo

it will take a little time to check it, yet I will get back to you :slight_smile:

very much appreciated :slight_smile: