Vilsol Posted November 26, 2010 Report Share Posted November 26, 2010 Tātad neliela problēma ar fxcanf funkciju... Scripts izskatās šādi: <?php $date = date('Y-n-j'); $file = 'C:\Users\Vilsol\Desktop\MineCraftServeris\logs\\'.$date.'.txt'; $handle = fopen($file); while ($userinfo = fscanf($handle, "\!PLAYERS ONLINE: %s\n")) { list ($name) = $userinfo; echo $name; } fclose($handle); ?> Bet man viņš neko nerāda... Pamēģināju ar echo $file un tads fails pastaav... Man vajag lai vinš no faila izvelk šādu rindiņu: !PLAYERS ONLINE: Anon73, Quaranty, Shrinkys112, ClayC, rickboy26, Redmaz, Fluffybunni2, hcy8 (cilvēku saraksts var atšķirties bet es domāju tos atdalīt ar explode...) bet viņš nerāda neko... lūdzu palīdziet paldies jau iepriekš :) Quote Link to comment Share on other sites More sharing options...
briedis Posted November 26, 2010 Report Share Posted November 26, 2010 Varbūt faila /jaunās rindiņas/ simbols ir \r\n nevis \n ? Quote Link to comment Share on other sites More sharing options...
Vilsol Posted November 26, 2010 Author Report Share Posted November 26, 2010 nestraadaa tikuntaa ps atklaaju ka scripts nespeeja atrast failu tapeec naacaas parmest uz weba direktoriju... tatad tagad scripts ir taads: <?php $date = date('Y-n-j'); $file = 'MineCraftServeris/logs/'.$date.'.txt'; $handle = fopen($file); while ($userinfo = fscanf($handle, "\!PLAYERS ONLINE: %s\r\n")) { list ($name) = $userinfo; echo $name; } fclose($handle); ?> Quote Link to comment Share on other sites More sharing options...
mounkuls Posted November 27, 2010 Report Share Posted November 27, 2010 fopen funkcijai laikam prasījās arī opcija...kādai darbībai to failu īsti gribi ņemt. Quote Link to comment Share on other sites More sharing options...
Vilsol Posted November 27, 2010 Author Report Share Posted November 27, 2010 nesaprotu ko tu domaa ar vaardu opcija... pagaidaam es gribu lai atverot lapu vinsh man paraada visas taas rindinjas... Quote Link to comment Share on other sites More sharing options...
php newbie Posted November 27, 2010 Report Share Posted November 27, 2010 http://lv.php.net/manual/en/function.fopen.php Quote Link to comment Share on other sites More sharing options...
Kverkagambo Posted November 27, 2010 Report Share Posted November 27, 2010 Vai tikai fscanf nelasa failu pa atsevišķai rindiņai. Pamēģini fscanf($handle, "%s") un paskaties. Quote Link to comment Share on other sites More sharing options...
Val Posted November 27, 2010 Report Share Posted November 27, 2010 Manuāli atver un izlasi; ja kļūdu paziņojumus būtu ieslēdzis, saprastu. ... $handle = fopen($file, 'r'); while ($userinfo = fscanf($handle, "!PLAYERS ONLINE: %[a-zA-Z0-9,. ]\r\n")) { ... Quote Link to comment Share on other sites More sharing options...
Vilsol Posted November 27, 2010 Author Report Share Posted November 27, 2010 tikuntā nav.... <?php $date = date('Y-n-j'); $file = 'MineCraftServeris/logs/'.$date.'.txt'; $handle = fopen($file, 'r'); while ($userinfo = fscanf($handle, "!PLAYERS ONLINE: %[a-zA-Z0-9,. ]\r\n")) { list ($name) = $userinfo; echo $name; } fclose($handle); ?> Quote Link to comment Share on other sites More sharing options...
Val Posted November 27, 2010 Report Share Posted November 27, 2010 (edited) Failu tiešām var atvērt lasīšanai? Edited November 27, 2010 by Val Quote Link to comment Share on other sites More sharing options...
Vilsol Posted November 27, 2010 Author Report Share Posted November 27, 2010 (edited) tikuntā nekas... <?php $date = date('Y-n-j'); $file = ''.$date.'.txt'; $file2 = 'MineCraftServeris/logs/'.$date.'.txt'; $handle = fopen($file, 'r'); while ($userinfo = fscanf($handle, "!PLAYERS ONLINE: %[a-zA-Z0-9,. ]\r\n")) { list ($name) = $userinfo; echo $name; } fclose($handle); ?> Edited November 27, 2010 by Vilsol Quote Link to comment Share on other sites More sharing options...
Vilsol Posted November 27, 2010 Author Report Share Posted November 27, 2010 up! Quote Link to comment Share on other sites More sharing options...
php newbie Posted November 28, 2010 Report Share Posted November 28, 2010 ieraksti koda sākumā error_reporting(E_ALL); ini_set("display_errors", 1); un apskaties kadas kļūdas izvadīs Quote Link to comment Share on other sites More sharing options...
Vilsol Posted November 28, 2010 Author Report Share Posted November 28, 2010 nekādas kļu'das nemet pamēģināju nomainīt nosaukuma failam tad tik izmeta... 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.