I've been apart of many marketing forums, and this is my first coding forum that I decided to join.
I'm working on some PHP code, to make a steal script. This allows you to steal gold from other players by comparing skill points, and generating a random number. The algorithmn is not completely done - it's just a simple code. The code is called from another page with the action leading to this file.
Now, my question is, why is there a syntax error to this code?
Thanks!
Code: Select all
<?php
include 'connect.php';
session_start();
?>
<!-- steal.php -->
<link rel="stylesheet" href="style.css" type="text/css">
<?php
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
$userstats="SELECT * from km_users where playername='$player'";
$userstats2=mysql_query($userstats) or die ("Could not get user stats");
$userstats3=mysql_fetch_array($userstats2);
$victim=$_POST['victim'];
$victim=strip_tags($victim);
$oppstats="SELECT * from km_users where playername='$victim'";
$oppstats2=mysql_query($oppstats) or die("Couldn't get Stats");
$oppstats3=mysql_fetch_array($oppstats2);
$totalstats=$oppstats3[skillpts]+$userstats3[skillpts];
$randomnumber=rand(1,5);
if ($randomnumber<=$yourstats3[skillpts])
{
$oppname=$oppstats[playername];
$randgold=$oppstats3[gold];
$earnings=rand(1,$randgold);
$pocketgold="update km_users set gold=gold+'$earnings' where
ID='$userstats3[ID]'";
$lowergold="update km_users set gold=gold-'$earnings' where
ID='$oppstats3[ID]'";
mysql_query($pocketgold) or die("Error: Could not add winnings");
mysql_query($lowergold) or die("Couldn't subtract gold from his pocket");
print "You successfully stole $earnings dollars from $oppname."
}
}
?>
</html>