matx Posted September 17, 2005 Report Share Posted September 17, 2005 kaads var paskaidrot kadelj man neizdodas ierakstiit neko txt failaa, daru sekojoshi: ir triis faili- index.php, apstradatajs.php, un dari.txt... index.php saturs: <form action="apstradatajs.php"> <input type="text" name="dati" style="width:200px; height:200px "> <input type="submit" value="Saglabāt"> </form> apstradatajs.php saturs: <?php $filename = 'dati.txt'; $somecontent = "$dati\n"; // Let's make sure the file exists and is writable first. if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle); } else { echo "The file $filename is not writable"; } ?> apstradatajs.php nokopeets no php.net maacoties par funkciju fwrite... es veeletos lai ierakstot info index.php formaa vinja tiktu saglabaata txt failaa, php.net $somecontent = "$dati\n"; $dati vietaa bija raxtiits texts, un tad aizejot uz apstradatajs.php txt failaa tika ierakstiits tas texts, bet es gribeetu lai no formas tas textinjsh aizietu uz txt failu.... varbuut varat kko ieteikt? paldies.... Link to comment Share on other sites More sharing options...
Aleksejs Posted September 17, 2005 Report Share Posted September 17, 2005 Vai es pareizi saprotu, ka tajā dari.txt nekas neierakstās? man škiet, ka problēma ir tajā, ka tu neesi pārliecinājies, vai register_globals ir on vai off... īsāk sakot... pamēģini šo savu rindiņu: $somecontent = "$dati\n"; aizvietot ar šo: $somecontent = $_GET['dati'] . "\n"; Link to comment Share on other sites More sharing options...
matx Posted September 17, 2005 Author Report Share Posted September 17, 2005 paldies aleksej, tagad sanaaca... un pie vainas bija register_globals? Link to comment Share on other sites More sharing options...
blackhalt Posted September 17, 2005 Report Share Posted September 17, 2005 paldies aleksej, tagad sanaaca... un pie vainas bija register_globals? 22479[/snapback] http://lv2.php.net/manual/en/security.globals.php http://lv2.php.net/manual/en/security.php Link to comment Share on other sites More sharing options...
matx Posted September 26, 2005 Author Report Share Posted September 26, 2005 atkal es :huh: un atkal liidziiga teema, meegjinaaju peec tutoriaala uzmeistarot gb, peec shii tutoriaalja erroru nav, tik atkal shams negrib raxtiit ieksh txt faila, register globals uzliku on bet vienalga neko neraxta.... varbuut ir kaadi ieteikumi, kaa to labot? Link to comment Share on other sites More sharing options...
Aleksejs Posted September 26, 2005 Report Share Posted September 26, 2005 (edited) Kurā tieši no tiem skriptiem un kā tieši nepareizā strādāšana izpaužās? Papēti, ko atgriež attiecībā uz tavu failu funkcijas: file_exists(); is_readable(); is_writable(); Edited September 26, 2005 by Aleksejs Link to comment Share on other sites More sharing options...
matx Posted September 26, 2005 Author Report Share Posted September 26, 2005 nu tur jau taa lieta, ka es neiebraucu kur tas viss vareetu nestraadaat... un tur jau tikai 1 skripts ir... es domaaju ka vaina vareetu buut kkur sheit global $gbfile; $tmp = trim($str); $fp=fopen($gbfile,'a+'); flock($fp, LOCK_EX); fwrite($fp, $tmp. "\n"); flock($fp, LOCK_UN); fclose($fp); } meegjinaju uzlikt vienkaarshi 'a' , bet arii tas neliidzeeja... domaaju maybe juus kko vareeetu ieteikt! Link to comment Share on other sites More sharing options...
Aleksejs Posted September 26, 2005 Report Share Posted September 26, 2005 ko iz echo, ja pārraksti šādi: global $gbfile; $tmp = trim($str); echo($gbfile . '<br>'); echo(''.(file_exists($gbfile)?'Fails atrasts<br>':'Fails nav atrasts<br>')); echo(''.(is_readable($gbfile)?'Failu var nolasīt<br>':'Failu nevar nolasīt<br>')); echo(''.(is_writable($gbfile)?'Failā var ierakstīt<br>':'Failā nevar ierakstīt<br>')); $fp=fopen($gbfile,'a+'); flock($fp, LOCK_EX); fwrite($fp, $tmp. "\n"); flock($fp, LOCK_UN); fclose($fp); } Link to comment Share on other sites More sharing options...
goldy Posted September 27, 2005 Report Share Posted September 27, 2005 lai no formas dabuutu ievadiitos datus ir jaalieto $_POST[] vai $_GET[], atkariiba no formas veida kas tev nav defineets pirmajaa piemeera apmeeram saadi <form action="apstradatajs.php" method='post'> <input type="text" name="dati"> <input type="submit" value="Saglabāt"> </form> un peec tam dati ir savaacami ar $somecontent = $_POST["dati"]; un nevajag sleegt ieksaa register_globals - palasi par security ieks php.net Link to comment Share on other sites More sharing options...
matx Posted September 28, 2005 Author Report Share Posted September 28, 2005 hmm.... tas guestbook uz eclub servera iet, bet uz mana shams neraxta txt failaa... maybe kads var pateikt kadelj taa? saprotu ka kkas ar php configuraaciju... bet kas? Link to comment Share on other sites More sharing options...
Kavacky Posted September 28, 2005 Report Share Posted September 28, 2005 Pasties te. Link to comment Share on other sites More sharing options...
Recommended Posts