Hi,
Im trying to import data from 3 txt.gz files and then import them into my mysql database.
I have searched the forums and cannot find what i am looking for
I made a script, but it doesnt work. Can anyone give me some help with it?
These are the txt.gz files im trying to import the data from
http://en2l1.ds.innogames.net/map/ally.txt.gz
http://en2l1.ds.innogames.net/map/tribe.txt.gz
http://en2l1.ds.innogames.net/map/village.txt.gz
heres the script
<?php
$host = 'hostname';
$username = 'username';
$password = 'password';
$database = 'database';
$connection = mysql_connect($host, $username, $password);
$mysql_select_db($database, $connection);
$lines = gzfile('http://en2l1.ds.innogames.net/map/village.txt.gz', 'r');
if(!is_array($lines)) die("File could not be opened");
foreach($lines as $line) {
list($id, $name,$x, $y, $player, $points, $rank) = explode(',', $line);
$name = urldecode($name);
$name = addslashes($name);
mysql_query("INSERT INTO village SET id='$id', name='$name', x='$x', y='$y',
player='$player', points='$points', rank='$rank'");
}
Villages
$lines = gzfile('http://en2l1.ds.innogames.net/map/tribe.txt.gz', 'r');
if(!is_array($lines)) die("File could not be opened");
foreach($lines as $line) {
list($id, $name, $ally, $villages, $points, $rank) = explode(',', $line);
$name = urldecode($name);
$name = addslashes($name);
mysql_query("INSERT INTO village SET id='$id', name='$name', ally='$ally', villages'$villages',
points='$points', rank='$rank'");
}
$lines = gzfile('http://en2l1.ds.innogames.net/map/ally.txt.gz', 'r');
if(!is_array($lines)) die("File could not be opened");
foreach($lines as $line) {
list($id, $name,$tag, $members, $villages, $points, $all_points, $rank) = explode(',', $line);
$name = urldecode($name);
$name = addslashes($name);
mysql_query("INSERT INTO village SET id='$id', name='$name', tag='$tag', members='$members',
villages='$villages', points='$points', all_points=$all_points, rank='$rank'");
}
mysql_close($connection);
?>
Id like to say thanks in advance to anoyone who can help me