Ved sgu ik hva fejlen er
Heya... Jeg er i gang med at lave en slags online spil.. min kode ser sårn her ud:<?
include("config.php");
$kode = "6";
$a = "10";
$b = "10";
$aspiller = "wickedwacko";
$bspiller = "nimda";
mysql_query("INSERT INTO kampe (ID, spillerA, spillerB, spillerApoint, spillerBpoint, vinder, kode, runder, slut) VALUES ('', '$aspiller', '$bspiller', '$a', '$b', '0', '$kode', '0', 'nej')") or die(mysql_error());
$sql = mysql_query("SELECT * from kampe where kode = '$kode'") OR DIE(mysql_error());
$row = mysql_fetch_assoc($sql);
$spillera = $row['spillerA'];
$spillerb = $row['spillerB'];
$SpillerASql = mysql_query("SELECT * FROM users where username = '$spillera'") OR DIE(mysql_error());
$SpillerARow = mysql_fetch_row($SpillerASql);
$SpillerBSql = mysql_query("SELECT * FROM users where username = '$spillerb'") OR DIE(mysql_error());
$SpillerBRow = mysql_fetch_row($SpillerBSql);
while ($row['vinder'] == "0" AND $row['runder'] == "0" AND $row['slut'] == "nej"){
if("$a" == "$b") {
$arand = rand(1,10);
$brand = rand(1,10);
$indsaetR = $row['runder']+1;
$fraa = $a-$arand;
$frab = $b-$brand;
// Trække rand tal fra point slut
// Lave procent start
$aprocent = $arand/$a*100;
$bprocent = $brand/$b*100;
// Lave procent slut
} else {
echo "FEJL!";
}
if(strlen($fraa <= 0 AND $frab >= 0)) {
echo "$spillera er død!";
echo "<br>";
echo "Mens $spillerb har <b>$bprocent</b> liv tilbage";
$AspillerApoint = $aprocent;
$AspillerBpoint = $bprocent;
$AindsaetA = $SpillerARow['point']-$ASpillerAPoint/10;
$AindsaetB = $SpillerBRow['point']+$ASpillerBPoint/10;
mysql_query("UPDATE users SET point = '$AindsaetA' where username = '$spillera'") or die(mysql_error());
mysql_query("UPDATE users SET point = '$AindsaetB' where username = '$spillerb'") or die(mysql_error());
mysql_query("UPDATE kampe SET slut = 'ja', spillerApoint = '$aprocent', spillerBpoint = '$bprocent', vinder = '$spillerb', runder = '$indsaetR' WHERE kode = '$kode'") or die(mysql_error());
} else {
echo "I døde sgu begge to";
mysql_query("UPDATE users SET point = '$AindsaetA' where username = '$spillera'") or die(mysql_error());
mysql_query("UPDATE users SET point = '$AindsaetB' where username = '$spillerb'") or die(mysql_error());
mysql_query("UPDATE kampe SET slut = 'ja', spillerApoint = '$aprocent', spillerBpoint = '$bprocent', vinder = '0', runder = '$indsaetR' WHERE kode = '$kode'") or die(mysql_error());
}
if(strlen($frab <= 0 AND $fraa >= 0)) {
echo "$spillerb er død!";
echo "<br>";
echo "Mens $spillera har <b>$aprocent</b> liv tilbage";
$BindsaetA = $SpillerARow['point']+$aprocent/10;
$BindsaetB = $SpillerBRow['point']-$bprocent/10;
mysql_query("UPDATE users SET point = '$BindsaetA' where username = '$spillera'") or die(mysql_error());
mysql_query("UPDATE users SET point = '$BindsaetB' where username = '$spillerb'") or die(mysql_error());
mysql_query("UPDATE kampe SET slut = 'ja', spillerApoint = '$aprocent', spillerBpoint = '$bprocent', vinder = '$spillera', runder = '$indsaetR' WHERE kode = '$kode'") or die(mysql_error());
} else {
echo "I døde sgu begge to";
mysql_query("UPDATE users SET point = '$BindsaetA' where username = '$spillera'") or die(mysql_error());
mysql_query("UPDATE users SET point = '$BindsaetB' where username = '$spillerb'") or die(mysql_error());
mysql_query("UPDATE kampe SET slut = 'ja', spillerApoint = '$aprocent', spillerBpoint = '$bprocent', vinder = '0', runder = '$indsaetR' WHERE kode = '$kode'") or die(mysql_error());
}
if(strlen($fraa AND $frab > 0)) {
echo "Ingen døde!";
echo "<br><br>";
echo "$spillera har $aprocent% liv tilbage og $spillerb har $bprocent% liv tilbage";
$CindsaetA = $SpillerARow['point']+$aprocent/10;
$CindsaetB = $SpillerBRow['point']-$bprocent/10;
mysql_query("UPDATE users SET point = '$CindsaetA' where username = '$spillera'") or die(mysql_error());
mysql_query("UPDATE users SET point = '$CindsaetB' where username = '$spillerb'") or die(mysql_error());
mysql_query("UPDATE kampe SET spillerApoint = '$aprocent', spillerBpoint = '$bprocent', vinder = '0', runder = '$indsaetR' WHERE kode = '$kode'") or die(mysql_error());
}
}
while ($row['runder'] != "0" AND $row['vinder'] == "0" AND $row['slut'] == 'nej') {
if("$a" == "$b") {
$arand = rand(1,10);
$brand = rand(1,10);
$indsaetR = $row['runder']+1;
$fraa = $a-$arand;
$frab = $b-$brand;
// Trække rand tal fra point slut
// Lave procent start
$aprocent = $arand/$a*100;
$bprocent = $brand/$b*100;
// Lave procent slut
} else {
echo "FEJL!";
}
$spillerAliv = $row['spillerApoint']-$aprocent;
$spillerBliv = $row['spillerBpoint']-$bprocent;
if(strlen($fraa <= 0 AND $frab >= 0)) {
echo "$spillera er død!";
echo "<br>";
echo "Mens $spillerb har <b>$spillerBliv %</b> liv tilbage";
$AindsaetA = $SpillerARow['point']-$SpillerAliv/10;
$AindsaetB = $SpillerBRow['point']+$SpillerBliv/10;
mysql_query("UPDATE users SET point = '$AindsaetA' where username = '$spillera'") or die(mysql_error());
mysql_query("UPDATE users SET point = '$AindsaetB' where username = '$spillerb'") or die(mysql_error());
mysql_query("UPDATE kampe SET slut = 'ja', spillerApoint = '$spillerAliv', spillerBpoint = '$spillerBliv', vinder = '$spillerb', runder = '$indsaetR' WHERE kode = '$kode'") or die(mysql_error());
} else {
echo "I døde sgu begge to";
mysql_query("UPDATE users SET point = '$AindsaetA' where username = '$spillera'") or die(mysql_error());
mysql_query("UPDATE users SET point = '$AindsaetB' where username = '$spillerb'") or die(mysql_error());
mysql_query("UPDATE kampe SET slut = 'ja', spillerApoint = '$spillerAliv', spillerBpoint = '$spillerBliv', vinder = 'uafgjort', runder = '$indsaetR' WHERE kode = '$kode'") or die(mysql_error());
}
if(strlen($frab <= 0 AND $fraa >= 0)) {
echo "$spillerb er død!";
echo "<br>";
echo "Mens $spillera har <b>$spillerAliv %</b> liv tilbage";
$BindsaetA = $SpillerARow['point']+$SpillerAliv/10;
$BindsaetB = $SpillerBRow['point']-$SpillerBliv/10;
mysql_query("UPDATE users SET point = '$AindsaetA' where username = '$spillera'") or die(mysql_error());
mysql_query("UPDATE users SET point = '$AindsaetB' where username = '$spillerb'") or die(mysql_error());
mysql_query("UPDATE kampe SET slut = 'ja', spillerApoint = '$spillerAliv', spillerBpoint = '$spillerBliv', vinder = '$spillera', runder = '$indsaetR' WHERE kode = '$kode'") or die(mysql_error());
} else {
echo "I døde sgu begge to";
mysql_query("UPDATE users SET point = '$AindsaetA' where username = '$spillera'") or die(mysql_error());
mysql_query("UPDATE users SET point = '$AindsaetB' where username = '$spillerb'") or die(mysql_error());
mysql_query("UPDATE kampe SET slut = 'ja', spillerApoint = '$spillerAliv', spillerBpoint = '$spillerBliv', vinder = '0', runder = '$indsaetR' WHERE kode = '$kode'") or die(mysql_error());
}
if(strlen($fraa AND $frab > 0)) {
echo "Ingen døde!";
echo "<br><br>";
echo "$spillera har $spillerAliv% liv tilbage og $spillerb har $spillerBliv% liv tilbage";
$blaA = $SpillerARow['point']+$SpillerAliv/10;
$blaB = $SpillerBRow['point']-$SpillerBliv/10;
mysql_query("UPDATE users SET point = '$blaA' where username = '$spillera'") or die(mysql_error());
mysql_query("UPDATE users SET point = '$blaB' where username = '$spillerb'") or die(mysql_error());
mysql_query("UPDATE kampe SET spillerApoint = '$spillerAliv', spillerBpoint = '$spillerBliv', vinder = '0', runder = '$indsaetR' WHERE kode = '$kode'") or die(mysql_error());
}
}
?>
Det skulle være muligt for jer at se hvad den skal kunne, men når jeg prøver at køre den så går den bare ind i et uendeligt loop :/
