• 01-08-2015, 14:25:40
    #1
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Arkadaşlar aşağıdaki kodla tarih alanındaki 2015-07 ile başlayan verileri listeliyorum. Echo ile ekrana bastığımda herhangi bir problem yok. Fakat amacım bu kayıtları txt yada csv içerisine kayıt ettirmek. fopen ile bunuda yapabiliyorum. Fakat sadece en son kaydın olduğu satırı kaydediyor dosyaya. Döngümde bir problemmi var?


    $listele = mysql_query("SELECT * FROM radacct where tarih like '2015-07%'  ");
    
    	while($cek=mysql_fetch_array($listele)){
    		
    		
    		$username			= $cek['username'];
    		$framedipaddress	= $cek['framedipaddress'];
    		$callingstationid 	        = $cek['callingstationid'];
    		$acctstarttime		= $cek['acctstarttime'];
    		$acctstoptime		= $cek['acctstoptime'];
    		
    			@extract ($username);
    			@extract ($framedipaddress);
    			@extract ($callingstationid);
    			@extract ($acctstarttime);
    			@extract ($acctstoptime);
    		
    				$birlestir = $username."\t".
    							 $framedipaddress."\t".
    							 $acctstarttime."\t".
    							 $callingstationid."\t".
    							 $acctstoptime;
    							 echo "\n";
    							 
    	
    				//LOG DOSYASI OLUŞTUR
    				$log_dosya_isim_yaz	= date("Y-m-d_H-i-s");
    				
    					$log_ac = fopen($log_dosya_isim_yaz.".txt", 'w');
    						fwrite($log_ac, $birlestir);
    						
    				echo $birlestir;			
    						
    	}
  • 01-08-2015, 17:16:03
    #2
    $log_ac = fopen($log_dosya_isim_yaz.".txt", 'w');

    w yaparsan her seferinde dosyayi bastan olusturur a yaparsan sonuna ekler.

    $log_ac = fopen($log_dosya_isim_yaz.".txt", 'a');
  • 01-08-2015, 17:29:27
    #3
                  //LOG DOSYASI OLUŞTUR 
                    $log_dosya_isim_yaz    = date("Y-m-d_H-i-s"); 
                     
                        $log_ac = fopen($log_dosya_isim_yaz.".txt", 'w'); // Dosya aç
    
    
    
    $listele = mysql_query("SELECT * FROM radacct where tarih like '2015-07%'  "); 
    
        while($cek=mysql_fetch_array($listele)){ 
             
             
            $username            = $cek['username']; 
            $framedipaddress    = $cek['framedipaddress']; 
            $callingstationid             = $cek['callingstationid']; 
            $acctstarttime        = $cek['acctstarttime']; 
            $acctstoptime        = $cek['acctstoptime']; 
             
                @extract ($username); 
                @extract ($framedipaddress); 
                @extract ($callingstationid); 
                @extract ($acctstarttime); 
                @extract ($acctstoptime); 
             
                    $birlestir = $username."\t". 
                                 $framedipaddress."\t". 
                                 $acctstarttime."\t". 
                                 $callingstationid."\t". 
                                 $acctstoptime; 
                                 echo "\n"; 
                                  
         
      
                            fwrite($log_ac, $birlestir); // Dosyaya yaz.
                             
                    echo $birlestir;             
                             
        }
    $log_ac = fopen($log_dosya_isim_yaz.".txt", 'w');

    Döngü içerisinde olduğundan her döngü sonrası tekrar kayıt yapıldığı için tek veri kaydediliyor.
  • 01-08-2015, 18:22:11
    #4
    Haha ben w'yu gorunce donguye bakmadan direk sallamisim

    Kutahyali adlı üyeden alıntı: mesajı görüntüle
                  //LOG DOSYASI OLUŞTUR 
                    $log_dosya_isim_yaz    = date("Y-m-d_H-i-s"); 
                     
                        $log_ac = fopen($log_dosya_isim_yaz.".txt", 'w'); // Dosya aç
    
    
    
    $listele = mysql_query("SELECT * FROM radacct where tarih like '2015-07%'  "); 
    
        while($cek=mysql_fetch_array($listele)){ 
             
             
            $username            = $cek['username']; 
            $framedipaddress    = $cek['framedipaddress']; 
            $callingstationid             = $cek['callingstationid']; 
            $acctstarttime        = $cek['acctstarttime']; 
            $acctstoptime        = $cek['acctstoptime']; 
             
                @extract ($username); 
                @extract ($framedipaddress); 
                @extract ($callingstationid); 
                @extract ($acctstarttime); 
                @extract ($acctstoptime); 
             
                    $birlestir = $username."\t". 
                                 $framedipaddress."\t". 
                                 $acctstarttime."\t". 
                                 $callingstationid."\t". 
                                 $acctstoptime; 
                                 echo "\n"; 
                                  
         
      
                            fwrite($log_ac, $birlestir); // Dosyaya yaz.
                             
                    echo $birlestir;             
                             
        }
    $log_ac = fopen($log_dosya_isim_yaz.".txt", 'w');

    Döngü içerisinde olduğundan her döngü sonrası tekrar kayıt yapıldığı için tek veri kaydediliyor.
  • 02-08-2015, 00:57:14
    #5
    Teşekkürler arkadaşlar. Çözüldü.

    $log_ac = fopen($log_dosya_isim_yaz.".txt", 'a');
  • 02-08-2015, 05:28:33
    #6
    MrNone adlı üyeden alıntı: mesajı görüntüle
    Teşekkürler arkadaşlar. Çözüldü.

    $log_ac = fopen($log_dosya_isim_yaz.".txt", 'a');
    Bu sorununu cozse de kullanimi yanlis, fopen'i dongu disina al