Monk3h Posted April 5, 2008 Share Posted April 5, 2008 Right, this Code 'Should work' and yet dosnt.. Its the PHP and not the SQL because instead of just displaying the 'else' Part of the code when i have Gembag as s it still displays the first bit. Now i know it gives me the gembag and changes it to 's' from 'n' in the database but it still only shows the first if part of the code and not the else. :s <?php $title = "Gem Store"; include("header.php"); ?> <b>Store Owner:</b> Welcome to my store! Here you can <i>Buy</i> and <i>Sell</i> many diferent Priceless Stones..<br><br><br> <?php if ($stat[gembag] = n ) { Print "<b>Store Assistant:</b> You dont appear to have a <i>Gem Bag</i>! How do you expect to collect all the precious stones that are available in this wonderful Town?<br><br>"; Print "<b>Store Assistant:</b> Here, take this.. Its on the house, but dont get telling people we do FreeBs!<br><br>"; Print "The store Assistant hands you a <b>Small Gem Bag</b>"; mysql_query("update players set gembag='s' where id=$stat[id]"); include("footer.php"); exit; } else { Print "<b>Store Assistant:</b> How are you getting on with that <i>Small Gem Bag</i>? Normally you could upgrade that tiny thing! (For a Small Fee) But right now we are out of Stock."; include("footer.php"); exit; } ?> <?php include("footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
fanfavorite Posted April 5, 2008 Share Posted April 5, 2008 Watch out for your if statements. if ($something = $somethingelse) { will return true. Add the double ==. if ($stat[gembag] == n ) { Quote Link to comment Share on other sites More sharing options...
Monk3h Posted April 5, 2008 Author Share Posted April 5, 2008 W00t.. Works now, Thanks dude! So Why do i need the Double == whats the diference? :S Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 5, 2008 Share Posted April 5, 2008 = is the assignment operator == is the equality operator They are (obviously) not equivalent. Quote Link to comment Share on other sites More sharing options...
Barand Posted April 5, 2008 Share Posted April 5, 2008 if ($something = $somethingelse) { will return true. Not if $something else contains 0 or false. Quote Link to comment 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.