Jump to content
MakeWebGames

Problem with gzfile() in php5.2


cpt_jack

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...