cpt_jack Posted February 9, 2009 Posted February 9, 2009 Hi i'm having problems with some code that imports tribalwars data into my DB, i know this code worked on my old server (php 4) but now that i have moved to a new one using php5.2 i get errors and i have googled for an hour and not found the answer :-) this is the code; <?php include '../config/config.php'; $lines = gzfile('http://en33.tribalwars.net/map/village.txt.gz', 'r'); if(!is_array($lines)) die("File could not be opened"); echo "</br>Clearing village database</br>"; mysql_query("truncate w1_villages"); foreach($lines as $line) { list($id, $name, $x, $y, $player, $points, $rank) = explode(',', $line); $name = urldecode($name); $name = addslashes($name); $y2=$y-($y%100); $x2=$x-($x%100); $continent=$y2/10+$x2/100; mysql_query("INSERT INTO w1_villages SET id='$id', name='$name', x='$x', y='$y', player='$player', points='$points', rank='$rank', continent='$continent'"); } ?> and the error is; Warning: gzfile() expects parameter 2 to be long, string given in /home/a9315141/public_html/crons/w1_village.php on line 5 File could not be opened please help before i start to cry and pull more of my hair out. Quote
Lithium Posted February 9, 2009 Posted February 9, 2009 Re: Problem with gzfile() in php5.2 As of the manual... You don't need the second parameter... gzfile('http://en33.tribalwars.net/map/village.txt.gz', 'r'); could be as gzfile('http://en33.tribalwars.net/map/village.txt.gz'); http://pt2.php.net/manual/en/function.gzfile.php Quote
Floydian Posted February 9, 2009 Posted February 9, 2009 Re: Problem with gzfile() in php5.2 The second parameter for gzfile is defined like this in the PHP manual: use_include_path You can set this optional parameter to 1, if you want to search for the file in the include_path too. So you can leave out that param, like was said already, or you can set it to 1. "r" or any other letter won't work there. :) Quote
cpt_jack Posted February 11, 2009 Author Posted February 11, 2009 Re: Problem with gzfile() in php5.2 Woohoo! worked like a charm :-D thanks guys/girls Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.