KarlisBa Posted February 20, 2008 Report Share Posted February 20, 2008 (edited) Šajā formā tiek ielādēta informācija: <form action="apstiprinat.php" method="post"> <textarea rows="20" cols="50" name="content"> <? $fn = "/edit/test.txt"; print htmlspecialchars(implode("",file($fn))); ?> </textarea><br> <input type="submit" value="Mainīt"> </form> Pēc apstiprināšanas nonāk uz failu apstiprinat.php, bet izmet šādu erroru Warning: fopen(/edit/test.txt) [function.fopen]: failed to open stream: No such file or directory in C:\AppServ\www\edit\apstiprinat.php on line 4 Nevar pārrakstīt! Šim skriptam: <? $fn = "/edit/test.txt"; $content = stripslashes($_POST['content']); $fp = fopen($fn,"w") or die ("Nevar pārrakstīt!"); fputs($fp,$content); fclose($fp) or die ("Error closing file!"); echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=windows-1257\" />\n"; ?> Kas par gļuku uz 4. rindas? Edited February 20, 2008 by shalonik Link to comment Share on other sites More sharing options...
Pentiums Posted February 20, 2008 Report Share Posted February 20, 2008 (edited) Warning: fopen(/edit/test.txt) [function.fopen]: failed to open stream: No such file or directory in C:\AppServ\www\edit\apstiprinat.php on line 4 Nevar pārrakstīt! tas jau visu izsaka.. /edit/test.txt tāds fails neeksistē pamēģini edit/test.txt bez sleša pirms edit! Edited February 20, 2008 by Pentiums Link to comment Share on other sites More sharing options...
KarlisBa Posted February 20, 2008 Author Report Share Posted February 20, 2008 A vakars aptumšo prātu. Reku bija vaina es tak SCRIPT ROOT nenorādīju atlika tikai pielikt ../ Kam negadās. :) $fn = "../edit/test.txt"; Link to comment Share on other sites More sharing options...
Mikijs Posted February 20, 2008 Report Share Posted February 20, 2008 (edited) <form action="apstiprinat.php" method="post"><textarea rows="20" cols="50" name="content"> <? $fn = "/edit/test.txt"; print htmlspecialchars(implode("",file($fn))); // Ja vel nepamaniji tad rekur <----- ?> </textarea><br> <input type="submit" value="Mainīt"> </form> Edited February 20, 2008 by Mikijs Link to comment Share on other sites More sharing options...
KarlisBa Posted February 20, 2008 Author Report Share Posted February 20, 2008 Nu strādā ar ja ir tie 3, bet vaitad nevajag 3. iekavas ? Jo kreisajā pusē jau ar ir trīs vai būšu, ko sajaucis? Link to comment Share on other sites More sharing options...
Mikijs Posted February 20, 2008 Report Share Posted February 20, 2008 :) mana kljuda :) nepamaniju 3; Link to comment Share on other sites More sharing options...
Mikijs Posted February 20, 2008 Report Share Posted February 20, 2008 Rakstit failaa <?php $vards = "vards"; $meils = "meils"; $fp = fopen("test.txt","a"); $fp = fopen("test.txt","a"); if(!$fp) { print "failu nevar atvert"; exit; } $stringtowrite=$vards."|".$meils; fwrite($fp, $stringtowrite); fclose($fp); ?> Lasīt no faila ātrākais un vieglākais variants ir <?php readfile("test.txt"); ?> nu bet =] <?php $array = file("test.txt"); foreach($array as $row) { $line = explode($row, "|"); print "Vards: $line[0], Meils: $line[1]<br>"; } print count($array); if (in_array("Arturs ",$array)) { print "Vards arturs nav saja faila<br>"; } srand ((float) microtime() * 10000000); $random_key=array_rand($array); $line = explode($array[$random_key], "|"); print "Luk tev randoms vards un meils: $line[0] : $line[1]<br>"; ?> Link to comment Share on other sites More sharing options...
Recommended Posts