-=HELLBENDER=- Posted December 22, 2010 Author Report Share Posted December 22, 2010 Failam ir jābūt, pat ja lieto 'w' opciju fopen, failu iztukšo un raksta no jauna. Pat ja neko neieraksta, failam ir jāpastāv. Es to biju domājis tā, ka viņš pasaka, ka fails neeksistē, lai gan tas fails vēl aiz vien tur ir un nav rediģēts. Quote Link to comment Share on other sites More sharing options...
mounkuls Posted December 23, 2010 Report Share Posted December 23, 2010 (edited) Tev sanāk file_exists("file")=false ? Tā nevar būt, ja vien nav kur unlink("file"); Ak jā, nav gadījumā tā, ka to failu meklē jau pirms esi izveidojis kādam jūzerim vai figviņzin kam? Bet vispār ieliec to kodu kaut vai paste.php.lv nevis failiem.lv lai var paskatīties. Edited December 23, 2010 by mounkuls Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted December 23, 2010 Report Share Posted December 23, 2010 Cik saprotu - iekš textarea tev faila saturs parādās, bet kad submit'o formu, tad saka, ka fails neeksistē. Ja tā, tad tas ir tapēc, ka submit'ojot formu tu nepadod tālāk fname $_GET parametru... Quote Link to comment Share on other sites More sharing options...
-=HELLBENDER=- Posted December 23, 2010 Author Report Share Posted December 23, 2010 Aplūko vēlreiz Viss tiek padots kā vajag. Nu labi, varbūt ne kā fname, bet content, bet nu tas neko nemaina. Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted December 23, 2010 Report Share Posted December 23, 2010 (edited) Jā bet submitojot to 'Edit' formu tu pazaudē savu fname $_GET parametru un tev paliek tikai tavs content $_POST parametrs, kas satur faila saturu... Debugo lai pārliecinātos - sākumā pieliec: var_dump($_GET); var_dump($_POST); Edited December 23, 2010 by rATRIJS Quote Link to comment Share on other sites More sharing options...
-=HELLBENDER=- Posted December 23, 2010 Author Report Share Posted December 23, 2010 Par to nezināju.. Un kā pārnest arī $_GET? :? Quote Link to comment Share on other sites More sharing options...
mounkuls Posted December 23, 2010 Report Share Posted December 23, 2010 Un šancēt tas viss laikam varētu arī tad, ja <form action="<?php echo $_SERVER["PHP_SELF"]."?fname=".$fn ?>" method="post"> jo arī post metodei get drīkst dot līdz. Quote Link to comment Share on other sites More sharing options...
-=HELLBENDER=- Posted December 23, 2010 Author Report Share Posted December 23, 2010 (edited) Warning: file_put_contents(<form action="edit.php" method="get"> Name: <input type="text" name="fname" /> <input type="submit" /> </form> ....) [function.file-put-contents]: failed to open stream: Invalid argument in edit.php on line 6 Pašlaik izskatās šādi; <?php$fn = $_REQUEST["fname"]; if (isset($_POST['content'])) { $fp = file_get_contents($fn, true) or die ("Error opening file in write mode!"); file_put_contents($fp,$content); } ?> <p> <form action="<?php echo $_SERVER["PHP_SELF"]."?fname=".$fn ?>" method="post"> <textarea rows="30" cols="80" name="content"><?php readfile($fn); ?></textarea> <input type="submit" value="Edit"> </form> Sestā līnija izcelta. ps. Warning'ā ir redzams atvērtā (fname) faila saturs. Edited December 23, 2010 by -=HELLBENDER=- Quote Link to comment Share on other sites More sharing options...
mounkuls Posted December 23, 2010 Report Share Posted December 23, 2010 Nu bet kurā vietā esi definējis to ko mēģini izdarīt file_put_contents($fp,$content);? $content jau nav definēts nekur... Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted December 23, 2010 Report Share Posted December 23, 2010 + $fp satur faila saturu :D Laikam jāieliek parakstā - "pirms prasi forumā vai debugoji (<- latviski būtu kā?) savu veikumu?" Quote Link to comment Share on other sites More sharing options...
mounkuls Posted December 23, 2010 Report Share Posted December 23, 2010 he he, pareizi, es pat neaizdomājos par to:D Quote Link to comment Share on other sites More sharing options...
-=HELLBENDER=- Posted December 23, 2010 Author Report Share Posted December 23, 2010 + $fp satur faila saturu :D Laikam jāieliek parakstā - "pirms prasi forumā vai debugoji (<- latviski būtu kā?) savu veikumu?" *facepalm*.. Paldies. Lai nu kā, nākamā problēma;; Faila saturs pirms edit'a; <form action="edit.php" method="get">Name: <input type="text" name="fname" /> <input type="submit" /> </form> Faila saturs pēc trijiem editiem (neko nemainot); <form action=\\\\\\\"edit.php\\\\\\\" method=\\\\\\\"get\\\\\\\">Name: <input type=\\\\\\\"text\\\\\\\" name=\\\\\\\"fname\\\\\\\" /> <input type=\\\\\\\"submit\\\\\\\" /> </form> Kapēc veidojās tie liekie \\ ? Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted December 23, 2010 Report Share Posted December 23, 2010 Ieteiktu php.ini izslēgt magic_quotes_qpc, tad nebūs jālieto stripslashes, un īsāk ir izmantot funkcijas - file_get_contents() un file_put_contents(). vai $content = stripslashes($content) Quote Link to comment Share on other sites More sharing options...
-=HELLBENDER=- Posted December 23, 2010 Author Report Share Posted December 23, 2010 Liels paldies (būtībā $content = stripslashes($_POST['content']); )! Apbrīnoju tādus cilvēkus kā jūs, kuriem pietiek pacietība skaidrot tādiem cilvēkiem kā man visādus sīkumus :D Quote Link to comment Share on other sites More sharing options...
mounkuls Posted December 23, 2010 Report Share Posted December 23, 2010 Arī mums savulaik ir nācies lauzt daudz šķēpu:) Es tinos gulēt, rīt astoņos darbā jābūt. Quote Link to comment 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.