marieanand Posted August 1, 2007 Share Posted August 1, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/62928-solved-reading-from-second-line-onwards/ Share on other sites More sharing options...
marieanand Posted August 1, 2007 Author Share Posted August 1, 2007 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); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/62928-solved-reading-from-second-line-onwards/#findComment-313331 Share on other sites More sharing options...
Crew-Portal Posted August 1, 2007 Share Posted August 1, 2007 use mysql... Less coding more sense! Quote Link to comment https://forums.phpfreaks.com/topic/62928-solved-reading-from-second-line-onwards/#findComment-313332 Share on other sites More sharing options...
marieanand Posted August 1, 2007 Author Share Posted August 1, 2007 Never mind, got it. Stupid me. Quote Link to comment https://forums.phpfreaks.com/topic/62928-solved-reading-from-second-line-onwards/#findComment-313341 Share on other sites More sharing options...
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.