Jump to content

adding some "if"s at end of script.


xwishmasterx

Recommended Posts

I have a this piece of code, and simply need to make the last piece work:

$amount = $_POST['amount'];
.........
$query = mysql_query("SELECT * FROM teams WHERE team_id='$te' ") 
or die(mysql_error());
$result = mysql_fetch_array( $query );
if($result['team_treasure'] <= '$amount'){
echo "<br><br><div align='center'>Transfer Failed: Not enough credits</div>  ";}
else
{
echo "<br><br><div align='center'>Transfer Completed!</div>";}

 

It returns Transfer Completed!, no matter if team_treasure is higher or lower than $amount

Link to comment
Share on other sites

Then echo the data to the page to validate your hypothesis. And, as GuiltyGear stated - compare it as a number, not a string

 

$amount = $_POST['amount'];

//.........

//Only query the field you need
$query = mysql_query("SELECT `team_treasure` FROM teams WHERE team_id='$te' ") 
    or die(mysql_error());
$result = mysql_fetch_assoc($query);
//Add a debug line:
echo "Result['team_treasure']:{$result['team_treasure']}, Amount:{$amount}<br>\n";
if($result['team_treasure'] <= '$amount')
{
    echo "<br><br><div align='center'>Transfer Failed: Not enough credits</div>  ";
}
else
{
    echo "<br><br><div align='center'>Transfer Completed!</div>";
}

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.