Toms Posted June 8, 2005 Report Share Posted June 8, 2005 (edited) Konkreeti ir shaadi: CSV failaa ir rindinja: 2001~sfgusgf~hgsfkskfg~wfswfsfs~shgfsiy~hgsgf Vinju vajag nolasiit un faila beigaas pielikt klaat jaunu rindinju ar mazliet savaadaaku info, piemeeram shaadi: 2001~sfgusgf~hgsfkskfg~wfswfsfs~shgfsiy~hgsgf 2001~sfsssss~cccc~zdgshsad~adgshsdgd~asfafs Bet rezultaataa ir shaadi: ~~~~~ 2001~sfsssss~cccc~zdgshsad~adgshsdgd~asfafs Vecie ieraksti vienkaarshi pazuud. Man ir Apache 2.0, php 4 un uz WinXp viss straadaa, nekas nekur nepazuud. Uzliku uz Linux, Zend - nekaa. Shitaada skaade radaas. NOLASIISHANA SHITAA: $x = 1; while (($data = fgetcsv($handle, 1000, "~")) !== FALSE) { $object[$x][1] = $data[0]; // 1- ObjectID -- used to know which picture... $object[$x][2] = $data[1]; // 2- Object $object[$x][3] = $data[2]; // 3- Name $object[$x][4] = $data[3]; // 4- Description $object[$x][5] = $data[4]; // 5- Contacts $object[$x][6] = $data[5]; // 6- Cost $x++; } UN PAARRAKSTIISHANA SHITAA: for ( $x=1; $x<=count($object); $x++ ){ $buffer .= $object[$x][1].'~'.$object[$x][2].'~'.$object[$x][3].'~'.$object[$x][4] .'~'.$object[$x][5].'~'.$object[$x][6]."\n"; } +peedeejaa rinda pievieno jauno rindinju, bet ... Megjinaaju ~ vietaa arii ; (semikolu), bet arii nekaa.. Kaapeec taa? Failiem visiem permisijas - 0777 Edited June 8, 2005 by Toms Link to comment Share on other sites More sharing options...
bubu Posted June 8, 2005 Report Share Posted June 8, 2005 Parādi kā tiek atvērts/aizvērts fails abos gadījumos un kā ieraksti to $buffer failā. Link to comment Share on other sites More sharing options...
Toms Posted June 8, 2005 Author Report Share Posted June 8, 2005 (edited) ATVER nolasishanai: $handle = fopen("data/data.en", "r"); Atver ierakstiishanai: $handle = fopen("data/data.en", "w+"); (protams peec nolasiisanas/ierakstiishanas arii ar fclose() aizveru) Ierakstu failaa shaadi: fwrite($handle, $buffer); EDIT: Peec nolasiishanas ar echo pameegjinaaju paskatiities, kas tajaa $object ierakstiits - TUKŠS!!! ieksh WinXP - pilns. Edited June 8, 2005 by Toms Link to comment Share on other sites More sharing options...
bubu Posted June 8, 2005 Report Share Posted June 8, 2005 (edited) echo $buffer; parāda visu buferi saliktu kopā no visām rindām pirms rakstīšanas? Un vispār kāpēc visu tu atmiņā gribi sakontkatenēt kopā ($buffer). Tas taču aizņems daudz atmiņas ja fails būs liels. Vai nav labāk rakstīt pa rindai tajā failā? Tb $buffer .= ... vietā ielikt fwrite(...); Edited: tam jau vairs nav nozīmes, ja pat neielasās nekas. tev error_reporting ir E_ALL ? Edited June 8, 2005 by bubu Link to comment Share on other sites More sharing options...
Toms Posted June 8, 2005 Author Report Share Posted June 8, 2005 (edited) Lieta taada, ka tas fails neizaugs liels - max 20 ieraksti. echo $buffer; <-- zem Win ir viss kaa vajag. zem Linux - truukst vecie ieraksti. Kaa jau mineeju, jau echo $object[1][1]; pie nolasiishanas izraadiijaas tukshs... EDIT: Jaa, man ir error_reporting E_ALL uz WinXP Neviena warninga, errora vai notices nav. Tikko Linuxam uzliku E_ALL un paraadiijaas shitas: Notice: Undefined offset: 1 in /srv/www/htdocs/blablabla.php on line 50 Vairaakaas taadas notices, un visas vinjas atrodas ieksh shii te WHILE cikla. Es saprotu, ka fgetcsv() nenostraadaa kaa vajag. kaapeec? $x = 1; while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) { $object[$x][1] = $data[0]; // 1- ObjectID -- used to know which picture... $object[$x][2] = $data[1]; // 2- Object $object[$x][3] = $data[2]; // 3- Name $object[$x][4] = $data[3]; // 4- Description $object[$x][5] = $data[4]; // 5- Contacts $object[$x][6] = $data[5]; // 6- Cost $x++; } Edited June 8, 2005 by Toms Link to comment Share on other sites More sharing options...
bubu Posted June 8, 2005 Report Share Posted June 8, 2005 A lasot vienkārši ar fgets() var nolasīt informāciju no tā paša faila Linuxī? Link to comment Share on other sites More sharing options...
Toms Posted June 8, 2005 Author Report Share Posted June 8, 2005 nee, nekas nenolasiijaas. un erroru arii neizmeta. Bet joks taads, ka failam pashaa saakumaa (pirmajaa rindinjaa) ir viens cipars, kuru gan var nolasiit (tikai ar fgetcsv(), bet ar fgets() neee.) Link to comment Share on other sites More sharing options...
bubu Posted June 8, 2005 Report Share Posted June 8, 2005 Tā taču nevar būt, ka pat fgets() nestrādā.. Kautkas dīvains tev tur. Link to comment Share on other sites More sharing options...
Toms Posted June 8, 2005 Author Report Share Posted June 8, 2005 jaa fgets() saaka straadaat, kad nomainiiiju 1000 uz 4096 Nomainiiju arii prieksh fgetcsv() 1000 uz 4096 bet nekaaa... fgetcsv($handle, 1000, ";") uz fgetcsv($handle, 4096, ";") Link to comment Share on other sites More sharing options...
Toms Posted June 8, 2005 Author Report Share Posted June 8, 2005 hahah, stulbums!!! Pirms ielasiishanas masiivaa $object (pirms while cikla) pievienoju rindinju: $object = array(); Un viss aizgaaja bez probleemaam. mlja. :wacko: Link to comment Share on other sites More sharing options...
bubu Posted June 8, 2005 Report Share Posted June 8, 2005 Tad jau būtu korekti arī tajā while ciklā ielikt iekšā: $object[$x] = array(); Jāmācās vien programmēt uz error_reporting(E_ALL). Link to comment Share on other sites More sharing options...
Recommended Posts