Michael_Tanner Posted June 6, 2009 Share Posted June 6, 2009 I'm currently trying to script something that requires me to script in PHP, of which I'm brand new to. I'm trying to make it read a specific file (that contains a number of course), and it loops through that number. I have files that should be labeled accordingly through each loop. So, if the number in the first file is '127', it loops 127 times and opens all .txt files between 1 and 127, though I can't get it to work. Here's the code: <html> <head> <title>Reloaded Gaming - IG Forum</title> </head> <body> <?php $handle = fopen("forumcount.txt", "r"); $filename = fread($handle, filesize("forumcount.txt")); $i = 1; while ( $i < $filename ) { $fi = '$i.txt'; <a link type="text" href="$fi" />Post $fi</a> $i++; } ?> </body> </html> Halpz plx. Quote Link to comment https://forums.phpfreaks.com/topic/161138-file-loop-thing/ Share on other sites More sharing options...
.josh Posted June 6, 2009 Share Posted June 6, 2009 I was all excited about helping you out until I got to Halpz plx. Quote Link to comment https://forums.phpfreaks.com/topic/161138-file-loop-thing/#findComment-850325 Share on other sites More sharing options...
Michael_Tanner Posted June 6, 2009 Author Share Posted June 6, 2009 I was all excited about helping you out until I got to Halpz plx. Orly, and why's that? Brb editing. Quote Link to comment https://forums.phpfreaks.com/topic/161138-file-loop-thing/#findComment-850326 Share on other sites More sharing options...
.josh Posted June 6, 2009 Share Posted June 6, 2009 I was all excited about helping you out until I got to Halpz plx. Orly, and why's that? Brb editing. Because I only understand English. So I have no idea what you're asking. Quote Link to comment https://forums.phpfreaks.com/topic/161138-file-loop-thing/#findComment-850327 Share on other sites More sharing options...
Michael_Tanner Posted June 6, 2009 Author Share Posted June 6, 2009 I was all excited about helping you out until I got to Halpz plx. Orly, and why's that? Brb editing. Because I only understand English. So I have no idea what you're asking. Je ne parle pas anglais. What I was asking is: "Could someone help me out?" Quote Link to comment https://forums.phpfreaks.com/topic/161138-file-loop-thing/#findComment-850329 Share on other sites More sharing options...
.josh Posted June 6, 2009 Share Posted June 6, 2009 Because I am dedicated and determined to be an outstanding pillar of this community, I have scoured the internet for a way for us to talk. http://www.moushigo.com/index.php/the-loler-project/ Ahem: I HAEV NO IEDA WUT U R SAYNG!1!111!1 OMG LOL SPAAK 3NGLISH LIEK A NURMAL HUMAN BNG THAN W3L TOK Quote Link to comment https://forums.phpfreaks.com/topic/161138-file-loop-thing/#findComment-850333 Share on other sites More sharing options...
Michael_Tanner Posted June 6, 2009 Author Share Posted June 6, 2009 Because I am dedicated and determined to be an outstanding pillar of this community, I have scoured the internet for a way for us to talk. http://www.moushigo.com/index.php/the-loler-project/ Ahem: I HAEV NO IEDA WUT U R SAYNG!1!111!1 OMG LOL SPAAK 3NGLISH LIEK A NURMAL HUMAN BNG THAN W3L TOK Thanks for the help. Could anyone else give me a solid answer? Quote Link to comment https://forums.phpfreaks.com/topic/161138-file-loop-thing/#findComment-850335 Share on other sites More sharing options...
.josh Posted June 6, 2009 Share Posted June 6, 2009 You know it would help if you were a bit less ambiguous than "I can't get it to work." First thing I see is $fi = '$i.txt'; single quotes do not parse variables. You need to do this: $fi = "{$i}.txt"; or $fi = $i . '.txt'; Quote Link to comment https://forums.phpfreaks.com/topic/161138-file-loop-thing/#findComment-850336 Share on other sites More sharing options...
allistera Posted June 6, 2009 Share Posted June 6, 2009 You also have "<a link type="text" href="$fi" />Post $fi</a>" in the middle of your PHP code. echo this line or break out the php code. Quote Link to comment https://forums.phpfreaks.com/topic/161138-file-loop-thing/#findComment-850362 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.