apw Posted October 20, 2008 Share Posted October 20, 2008 Hello I'm working on a script that handles the form add, subtracts and even multiplies the variables and queries the SQL. When player registers, the player receives the following: * 100 peasants * 0 labor * 0 manpower The script changes the players number of peasants to labor .. when player changes the labor amount, the player also receives 2-points per labor receives: Please check over the script, the peasants, labor and manpower isn't changing... ajobs.php (form action handle) <?php if ($userstats3[peasants]<=0) { print "Not enough peasants"; } else { print "You have $userstats3[peasants] peasants available!<br>"; print "<form action='ajob.php' method='post'>"; print "<input type='text' name='lesspeasant' size='5'><br>"; print "<input type='submit' name='submit' value='Change'></form>"; } ?> [/code] from ajob.php (handles the query with math) <?php include 'connect.php'; session_start(); ?> <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); if(isset($_POST['submit'])) { $lesspeasant=$_POST['lesspeasant']; $lesspeasant=strip_tags($lesspeasant); $lesslaboe=$_POST['lesslabor']; $lesslabor=strip_tags($lesslabor); print "<center>"; print "<table class='maintable'>"; print "<tr class='headline'><td><center>Buy Science</center></td></tr>"; print "<tr class='mainrow'><td>"; if($peasant<0) { print "You cannot change, not enough peasants!. Back to <A href='index.php'>Main</a>"; } else if($userstats3[playerturns]<1) { die("You must have at least 1 turn to Change. Go back to <A href='index.php'>Main</a>"); } $lesspeasants=$userstats3[peasants]; $lesspeasant=$userstats3[peasants]-$lesspeasant; $lesslabor=$lesspeasant; $userstats3[labor]=$lesspeasant; $userstats3[labor]*2; $updatestats="update km_users set peasants=peasants-'$lesspeasant', playerturns=playerturns-1 where ID='$userstats3[iD]'"; mysql_query($updatestats) or die("Could not update stats"); print "You Changed $lesspeasant peasants to labor and have $manpower manpower and $userstats3[labor] laborers! Back to <A href='index.php'>Main Page</a>"; } print "</td></tr></table>"; } else { print "Sorry, not logged in please <A href='login.php'>Login</a><br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/129308-sql-query/ Share on other sites More sharing options...
AndyB Posted October 20, 2008 Share Posted October 20, 2008 $lesslaboe=$_POST['lesslabor']; should be $lesslabor=$_POST['lesslabor']; shouldn't it? Quote Link to comment https://forums.phpfreaks.com/topic/129308-sql-query/#findComment-670400 Share on other sites More sharing options...
apw Posted October 21, 2008 Author Share Posted October 21, 2008 Yes that has been changed yet still the script doesnt execute and print the right result .. Is the portion above the sql_query correct with peasan=peasant-'$lesspeasant' and so forth? Quote Link to comment https://forums.phpfreaks.com/topic/129308-sql-query/#findComment-671194 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.