#!/usr/bin/env php \n"); } // Connect to the database $db = new PDO("mysql:{$host}=localhost;dbname={$dbname};charset=utf8mb4", $username, $password); // Alternatively connect to MySQL using the old interface // Comment the PDO statement above and uncomment the mysql_ calls // below if your PHP installation doesn't support PDO : // $db = mysql_connect("localhost", "root", ""); // mysql_select_db("test", $db); // Instanciate a new DBIP object with the database connection $dbip = new DBIP($db); // Alternatively instanciate a DBIP_MySQL object // Comment the new statement above and uncomment below if your PHP // installation doesn't support PDO : // $dbip = new DBIPMySQL($db); // Lookup an IP address $inf = $dbip->lookup($argv[1], $table); // Show the associated country echo "t:".$table." country = " . $inf->country . "\n"; $inf = $dbip->lookup($argv[1], $table_2); // Show the associated country echo "t:".$table_2." country = " . $inf->country . "\n"; } catch (DBIPException $e) { echo "error: {$e->getMessage()}\n"; exit(1); }