Jump to content

Recommended Posts

Hi! This is probably a silly question, but this is my first time using PHP.

 

What I'm trying to do is read .txt files numbered 0-99 (0.txt, 1.txt, etc) that have forum usernames, passwords, etc, separated by |, with different users on each line. Once I gain all that information, I plug it into a script I need for something else, and everything works fine and great.

 

Only... I don't know how to have it start reading the second line, third line, etc. after it's read the first.

 

Help would be greatly appreciated. Thanks! :)

 

Link to comment
https://forums.phpfreaks.com/topic/62928-solved-reading-from-second-line-onwards/
Share on other sites

My code:

 

<?php

 

$DOCUMENT_ROOT = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];

$num = 0;

 

for ($num == 0; $num >= 0; $num++) // & $num < 100

 

{

 

$myFile = "$num.txt";

$fh = fopen($myFile, 'r');

 

$num2 = $num + 3;

 

$myFile = "$num.txt";

$fh = fopen($myFile, 'r');

echo $theData;

 

$theData = fgets($fh); 

 

$pieces = explode("|", $theData);

 

$user = $pieces[0];

$password = md5($pieces[1]);

$email = $pieces[2];

$location = $pieces[3];

$occ = $pieces[4];

$website = $pieces[5];

 

 

echo "<textarea rows=20 cols=100>INSERT INTO phpbb_users (user_id, user_active, username, user_password, user_session_time, user_session_page, user_lastvisit, user_regdate, user_level, user_posts, user_timezone, user_style, user_lang, user_dateformat, user_new_privmsg, user_unread_privmsg, user_last_privmsg, user_login_tries, user_last_login_try, user_emailtime, user_viewemail, user_attachsig, user_allowhtml, user_allowbbcode, user_allowsmile, user_allowavatar, user_allow_pm, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_rank, user_avatar, user_avatar_type, user_email, user_icq, user_website, user_from, user_sig, user_sig_bbcode_uid, user_aim, user_yim, user_msnm, user_occ, user_interests, user_actkey, user_newpasswd) VALUES('$num2', '1', '$user', '$password', '1185834719', '0', '1185488270', '1185483404', '0', '0', '0.00', '1', 'english', 'd M Y h:i a', '0', '0', '0', '0', '0', NULL, '1', '0', '0', '$website', '1', '1', '1', '1', '0', '1', '1', '0', '', '0', '$email', '', '', '$location', '', NULL, '', '', '', '$occ', '', '', '')</textarea>";

 

 

fclose($fh);

 

 

}

 

 

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.