Jump to content

not updating.


grlayouts

Recommended Posts

my code should update the cash and drugs of a player when he sells but its not working.

 

<?php
print "<form method=post action=enterprises.php?view=add&step=add>Sell <input name=amount><select name=seller><option value=Drugs>Drugs</option></select>. <input type=submit value=Sell></form>";
if ($step == "Sell") 
{
switch($seller)
{
	case "Drugs":
		if ($stat[drugs] < $amount) {
			print "Sorry mate, you don't have the drugs.";
		} else {
			mysql_query("update players set drugs=drugs-$amount where id=$stat[id]");
			mysql_query("update players set credits=$amount*$stat[drugprice] where id=$stat[id]");
			print "You sold $amount of drugs."; 
		}
?>

Link to comment
Share on other sites

ok, well instead of gooing:

 

";skdjfghlskdjfhg $VARIABLE fkdghsldfkjghslkjdfgh"

 

use

 

"aksjdfhalkjgh".$VARIABLE.",khdgksjdghkjagf";

 

also, do you have to include the database connection variable for the query, i use mysqli and that requires it???

 

 

if that doesnt work.  where you have a calculation, actually store the result of the calculation in another variable and use that variable for the string.

 

 

good luck

 

Link to comment
Share on other sites

paste this code into the bottome of your page, as the very last line before the end tag

 

itll display every variable, array in the entire page, even the globals that you dont set

 

 

 

youll get whatever output the page gives, then this long list.

 

 

also, stor the querys in variable ie $var1 = mysql_query() etc.

 

then look for the $var1 in the long list and place value here

 

if the value is mysql_result_object, or somethig similar, then store another 4 variables $result1 and 2, and for each go $result1 = mysql_fetch_array($query1variable);

 

then look for these new variables and paste them herein the forum

 

 

 

 

this will tell us whether of not the query is returning anything.....

 

 

good luck

Link to comment
Share on other sites

<?php
print "<form method=post action=enterprises.php?view=add&step=add>Sell <input name=amount><select name=seller><option value=Drugs>Drugs</option></select>. <input type=submit value=Sell></form>";
if ($step == "Sell") 
{
switch($seller)
{
	case "Drugs":
		if ($stat['drugs'] < $amount) {
			print "Sorry mate, you don't have the drugs.";
		} else {
			mysql_query("update players set drugs=(drugs-$amount) where id=".$stat[id]) OR DIE(mysql_error());
			mysql_query("update players set credits=($amount*".$stat['drugprice'].") where id=".$stat['id']) DIE(mysql_error());
			print "You sold $amount of drugs."; 
		}
?>

 

Try that out. Sometimes calling from arrays, especially like the index is a constant does weird stuff. Also added parans as they are generally a good idea when doing ANY type of math function. If that still does not work report back the error.

Link to comment
Share on other sites

<?php
print "<form method=post action=enterprises.php?view=add&step=add>Sell <input name=amount><select name=seller><option value=Drugs>Drugs</option></select>. <input type=submit value=Sell></form>";
if ($step == "Sell") 
{
switch($seller)
{
	case "Drugs":
		if ($stat['drugs'] < $amount) {
			print "Sorry mate, you don't have the drugs.";
		} else {
			mysql_query("update players set drugs=(drugs-$amount) where id=".$stat[id]) OR DIE(mysql_error());
			mysql_query("update players set credits=($amount*".$stat['drugprice'].") where id=".$stat['id']) DIE(mysql_error());
			print "You sold $amount of drugs."; 
		}
                     break;
         }
?>

 

I would of hopped you could of fixed the syntax, guess I was wrong.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.