SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    Feb 2012
    Location
    Kiwi in Bangkok
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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`);";

  2. #2
    SitePoint Addict
    Join Date
    Apr 2011
    Posts
    265
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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:
    Code:
    $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`)";
    Free: Web Programming Courses HTML, CSS, Flash
    Web Programming: AJAX Course and PHP-MySQL Course video Lessons
    Good JavaScript and jQuery course for beginners

  3. #3
    SitePoint Addict
    Join Date
    Feb 2012
    Location
    Kiwi in Bangkok
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Marplo 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

    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 ...

  4. #4
    SitePoint Addict
    Join Date
    Apr 2011
    Posts
    265
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    The code seems correct, but you'll know better if you use it .
    Free: Web Programming Courses HTML, CSS, Flash
    Web Programming: AJAX Course and PHP-MySQL Course video Lessons
    Good JavaScript and jQuery course for beginners

  5. #5
    SitePoint Addict
    Join Date
    Feb 2012
    Location
    Kiwi in Bangkok
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello

    I get a SQL Error for the ($db_desc[] = "Creating <b>ip2nation</b> table" below the dotted line,

    all help appreciated

    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`);";

  6. #6
    SitePoint Addict
    Join Date
    Apr 2011
    Posts
    265
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    It is missing the closing ")" , try this:
    Code:
    $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`))";
    Free: Web Programming Courses HTML, CSS, Flash
    Web Programming: AJAX Course and PHP-MySQL Course video Lessons
    Good JavaScript and jQuery course for beginners

  7. #7
    SitePoint Addict
    Join Date
    Feb 2012
    Location
    Kiwi in Bangkok
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you MarPlo

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

    very much appreciated

    Quote Originally Posted by MarPlo View Post
    Hi,
    It is missing the closing ")" , try this:
    Code:
    $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`))";


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •