txt file parser

WILD

Administrator
Staff member
ADMIN
SELLER
SUPREME
MEMBER
Joined
Jan 21, 2025
Messages
219
Reaction score
631
Deposit
0$
$mysqlhost = "localhost"; // Хост
$mysqluser = "admin"; // Имя пользователя
$mysqlpassword = "qwerty"; // Пароль
$name = "base"; // Имя базы данных
$mysqlconnect = mysql_connect($mysqlhost, $mysqluser, $mysqlpassword);
mysql_select_db($mysqlname, $mysqlconnect);
$handle = fopen('file.txt', 'r');
$i=0;
while (!feof($handle)) {
$tmp = str_replace("\r\n",'',fgets($handle, 4096));
$tmp = preg_replace("~Name1: ~",'', $tmp);
$tmp = preg_replace("~Name2: ~",'', $tmp);
if(!empty($tmp)){
$file_array[$i++] = $tmp;
if($i==3){
mysql_query('INSERT INTO `table` (`name1`,`name2`) VALUES ("'.$file_array[1].'","'.$file_array[2].'")', $mysqlconnect);


$i=0;
}
}
}
fclose($handle);
mysql_close($mysqlconnect);
The parser parses a TXT file and enters the data from the file into MySQL.
I launched this parser, and after a couple of minutes, a 500 internal server error appeared. But the code has been running and entering the data into the MySQL database for two hours now.
Why is it still running?

The file we're parsing looks like this:
Name0: khjghjjh
Name1: 76546346536354235475678686
Name2: 7865454323525354563525234756
Name0: utggloiuyrtffuyguh
Name1: 876546345678867546789
Name2: 98776576436764575766878
Name0: iuoyyhbvghgjhlihkkhg
Name1: 767676754343435667875
Name2: 123456876534654767
etc......
The file itself is 1.5 gigs in size
 
Top Bottom