andrisp Posted July 21, 2008 Report Posted July 21, 2008 (edited) Ko tad ? Tu jau neesi uzdevis nekādu jautājumu vēl. PS. fopen, fwrite. Edited July 21, 2008 by andrisp
xfr33 Posted July 21, 2008 Author Report Posted July 21, 2008 tātad lietojot fopen var atvērt failu, kuru izmainīt var ar fwrite? un kā pēc tam saglabāt? nevar katru reizi jaunu failu taisīt? un likt viņus visus mapē kuru es nodefinēju!
andrisp Posted July 21, 2008 Report Posted July 21, 2008 (edited) Protams, ka var. Skaties manuālī. php.net/fopen, php.net/fwrite Edited July 21, 2008 by andrisp
xfr33 Posted July 21, 2008 Author Report Posted July 21, 2008 (edited) ok paldies :) Edited July 21, 2008 by xfr33
xfr33 Posted July 21, 2008 Author Report Posted July 21, 2008 šis te piemērs <?php $fp = fopen('data.txt', 'w'); fwrite($fp, '1'); fwrite($fp, '23'); fclose($fp); // the content of 'data.txt' is now 123 and not 23! ?> cik noprotu tad atver failu data.txt un pieliek klāt 123 un pēc tam aizver. pareizi sapratu? tas kas jau ir tai failā bijis ierakstīts tas paliek tur?
Aleksejs Posted July 21, 2008 Report Posted July 21, 2008 Nē, nepaliek. Skaties te: http://lv.php.net/manual/en/function.fopen.php A list of possible modes for fopen() using mode mode Description'r' Open for reading only; place the file pointer at the beginning of the file. 'r+' Open for reading and writing; place the file pointer at the beginning of the file. 'w' Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it. 'w+' Open for reading and writing; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it. 'a' Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it. 'a+' Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it. 'x' Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call. 'x+' Create and open for reading and writing; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call.
xfr33 Posted July 21, 2008 Author Report Posted July 21, 2008 ok man tagad tiek viss rakstīts failā data.txt! ņēmu to "a"! kā var izveidot jaunu failu pie katras jaunas atvēršanas? tikai lai faila nosaukums visu laiku būtu teiksim tās firmas nosaukums ( iepriekšējā formā tiek ievadīts firmas nosaukums )? :)
andrisp Posted July 21, 2008 Report Posted July 21, 2008 xfr33, sāc taču domāt! Tu nemāki datus no formas paņemt ? Tu nemāki tos pašus datus padot arī fopen funkcijai ?
xfr33 Posted July 21, 2008 Author Report Posted July 21, 2008 andri ok, viss aizgāja :D paldies liels! :) bet man varētu būt vēl viens jautājums, bet to vēlāk, ja neaizies :D
xfr33 Posted July 21, 2008 Author Report Posted July 21, 2008 nu tātad man aizpildot formu esmu sataisijis lai taisa jaunus failus ar pareizajiem nosaukumiem un ta talāk, bet vajadzigs sekojošais: 1. ieiet lapā, aizpilda formu. 2. aiziet uz nākamo lapu, kura izveido jaunu txt failu 3. neko nespiežot iet uz manis nodefinētu lapu! trešo punktu nemāku :( :D
andrisp Posted July 21, 2008 Report Posted July 21, 2008 header('Location: bla bla') ? Pats taču savos koda piemēros jau izmantoji to.
marcis Posted July 21, 2008 Report Posted July 21, 2008 header("Location: http://tevis.definēta.lapa");
xfr33 Posted July 21, 2008 Author Report Posted July 21, 2008 nu cmon šito kodu es zināju, bet kad ierakstu man rādas kļūda! Kļūda Warning: Cannot modify header information - headers already sent by (output started at C:\WEB\htdocs\write.php:12) in C:\WEB\htdocs\write.php on line 17
andrisp Posted July 21, 2008 Report Posted July 21, 2008 Nu ko tad tu prasi, ja jau zināji ? Un par šito kļūdu: http://php.lv/f/index.php?showtopic=7294
Recommended Posts