Jump to content

Database Won't Update


SoireeExtreme

Recommended Posts

I have an attack script that I've been working on. Which was fine. Then I added in the $update and now it doesn't do the mysql part of the script. Could anyone look this over and tell me why my database isn't updating? And give me any help possible? Because as you see players are suppose to lose and gain things. But nothing is changing it all stays the same. Thanks in advance.

[code]<?php
if (isset($_SESSION['player']))
  {
    $player=$_SESSION['player'];
    $userstats="SELECT * from ac_users where playername='$player'";
    $userstats2=mysql_query($userstats) or die("Could not get user stats");
    $userstats3=mysql_fetch_array($userstats2);

$atk1=$userstats3['atkskill']+$userstats3['offarmy'];

if (!isset($_GET['ID'])) {
  print "No player was selected to attack.<br>";
} else {
  $playerID = $_GET['ID'];
}

$playertwo="SELECT * from ac_users where ID='$playerID'";
$playertwo2=mysql_query($playertwo) or die("Blah");
$playertwo3=mysql_fetch_array($playertwo2);

$atk2=$playertwo3['defend']+$playertwo3['dffarmy'];

if($userstats3['numturns']<5)
{
print "<center>You need 5 turns to fight a player.";
}
else
{
echo "<center><u>Player Challenge</u><P>";

echo "$userstats3[playername] VS $playertwo3[playername]";

$update=$userstats3['gold']/4;
$update2=$playertwo3['gold']/4;

$update3=$userstats3['offarmy']/4;
$update4=$playertwo3['dffarmy']/4;

if($atk1>$atk2)
{
echo "<center>You Won! You Lost: Off Army $update4, Attack $update4, You gained: $update2 Gold, and 1 Respect Point.<br>
$playertwo3[playername] lost: Dff Army $update3, Defence $update3, $update2 Gold, and 1 Respect Point.";

$skill="update ac_users set offarmy=offarmy-'$update4' atkskill=atkskill-'$update4', honor=honor+'1', gold=gold+'$update2', numturns=numturns-'5' where playername='$player'";
mysql_query($skill);

$skill2="update ac_users set dffarmy=dffarmy-'$update3' defend=defend-'$update3', gold=gold-'$update2', honor=honor-'1'  where ID='$playerID'";
mysql_query($skill2);
}
else

if($atk2>$atk1)
{
echo "<center>You Lose! $playertwo3[playername] gained: and 1 Respect Point and lost Dff Army $update3, Defence $update3.<br>
You lost:Off Army $update4, Attack $update4 1 Respect Point. ";

$skill2="update ac_users set dffarmy=dffarmy-'$update3' defend=dfend-'$update3', honor=honor+'1' where ID='$playertwo3[ID]'";
mysql_query($skill2);

$skill="update ac_users set offarmy=offarmy-'$update4' atkskill=atkskill-'$update4', honor=honor-'1', numturns=numturns-'5' where playername='$player'";
mysql_query($skill);
}
else
if($atk1=$atk2)
{
echo "<center>Its a Draw. Neither player would win the fight. So in other
words you earn no reward.";

$skill="update ac_users set numturns=numturns-'5' where playername='$player'";
mysql_query($skill);
}
}
}
else
{
print "Nope";
}
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/27821-database-wont-update/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.