Jump to content

Zyse

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Zyse's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. still stewing over retarded code, with no new leads on a solution.
  2. I thanks you for your reply, but Im not quite understanding, if you could teach the context you were using and where it would be placed, :3
  3. would fgets be the best way to go about this?
  4. Im trying to learn how to place a read file line by line and prevent duplicate entries and also BLANK entries, into my process php script, using feof, I have failed many times and get so many errors such as syntax expecting . or , and so forth this is my process.php <?php $File = "links.txt"; $Handle = fopen($File, 'a'); $Data = "".$_POST['ID']; fwrite($Handle, $Data."\n"); print "Data Added\n"; fclose($Handle); ?> <?php countLines("links.txt"); function countLines($filepath) { $handle = fopen( $filepath, "r" ); $count = 0; while( fgets($handle) ) { $count++; } fclose($handle); return $count; } ?> <head> <meta http-equiv="REFRESH" content="5;test1.php"></HEAD> <br> please wait... navigating back! I got fed up and deleted all my work, to start from scratch, if feof($_POST['ID']) { alert 'Already entered'; return; } that was just one of my attempts also im unsure if putting in /n would make it look for /n or new line, if it looks for new line and every file has the new line marker would it always return as the data was already entered? Thanks in advance for assistance/teaching!
  5. Ah I see I see, Ill get to work on that. Thanks again for all your help, ill mark this as solved for now. :3 ty for teaching me
  6. how do I make it where it will look for an entry and not add duplicates? been looking forever XD
  7. So I pretty much have it almost complete, ill post in a bti after a couple more tests.
  8. <?php srand ((double)microtime()*1000000); $f_contents = file ("links.txt"); $line = $f_contents[array_rand ($f_contents)]; echo "<FORM METHOD="."LINK"." ACTION=".$line."> <INPUT TYPE="."submit"." VALUE="."Random"."> </FORM>"; ?> <form><input type=button value="refresh" onClick="window.location.reload()"></form> Ive got this for getting a random line and going to a url ith it, but cant figure out how to make it 1 button that refreshed after clicking, as well is how to set the target as a frame, was it target="framename"?
  9. <?php srand ((double)microtime()*1000000); $f_contents = file ("links.txt"); $line = $f_contents[array_rand ($f_contents)]; print $line; ?> for the grabbing of random line.
  10. <?php echo countLines("links.txt"); function countLines($filepath) { $handle = fopen( $filepath, "r" ); $count = 0; while( fgets($handle) ) { $count++; } fclose($handle); return $count; } ?> I also found that this can also be used as an increment, using this seems to avoind the constant loop or hang up, would this be a better method to count lines in order to grab a random one as an url? Edit Found out how to call a random line from file seems to work but pulls up the first line most of the time.
  11. <?php $file = "links.txt"; $lines = count(file($file)); echo " " .$lines. " lines in total"; ?> I found a tut for this and it counts the lines, but is this to simple in order for it to grab a random line it counted?
  12. I am sorry, I'm trying to learn I have been staring at that page you linked me to figure it out, but my brain is full XD, ok im trying I promise. OMG I know what I was doing wrong why I couldnt get the last script to work... im such a tard. I was trying to open the file without using the browser >.>. ok ok im on the same page now. Hmm it seems to loop indefinitely, I also changed the echo to print, if thats ok in the coding for referencing later. Bah it then loops and errors an infinite amount of these on a page Warning: feof() expects parameter 1 to be resource, boolean given in C:\wamp\www\ran\process.php on line 13 while (!feof($fp))
  13. Bah im getting no luck in verifying its reading the file >_< im using the code as posted.
  14. where would I incorperate this style of code, by using it is there a echo I can use to tell me how many lines there are to make sure its reading correctly?
  15. Ty for your replay, I just ignored the missing f and added it in thinking nothing of the typo so I already got that one, but im more looking for a sandom like rather then specific, my last thing I need is it to open a random line as url to a frame on the right,, but ty so much, ill be back tomorrow.
×
×
  • 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.