I did something like this its working good as i wish but feof part is not working so my loop does not stop at the end of the file its looping forever.
my txt file is
pvp.txt
Osman AppSc 60 10 Olympos
dakkar pvpci 52 8 freedom
and my php file is :
<?
@mysql_connect("localhost", "Dakkar", "")
or die("Veritabani ile baglanti kurulamadi!");
@mysql_select_db("uopvp")
or die("Veritabaninda bir hata olustu!");
$lines = file("pvp.txt");
$fname = fopen("pvp.txt","r");
for ($i=0;!feof($fname);$i++) {
list($account, $name, $puan, $kills, $guild) = explode(" ",$lines[$i]);
echo "$account<br>";
$sql = "SELECT count(*) FROM pvp WHERE account='$account' and name='$name' ";
$res = mysql_query($sql) OR die(mysql_error());
$row = mysql_fetch_row($res);
if($row[0] == 0) {
@mysql_query("insert into pvp values('','$account','$name','$puan','$kills','$guild','')");
echo "<center><b>Your Data Has Been Inserted.</b></center>";
}
else {
mysql_query("UPDATE pvp SET puan='$puan' WHERE account='$account' and name='$name'");
mysql_query("UPDATE pvp SET guild='$guild' WHERE account='$account' and name='$name'");
mysql_query("UPDATE pvp SET kills='$kills' WHERE account='$account' and name='$name'");
echo "<center><b>Your Data Has Been Updated.</b></center>";
}
}
?>
where is the wrong
or do i have to put something to end of txt file for impliying the end of file