Jump to content

Problem using Elseif


Monk3h

Recommended Posts

I dont understand what iv done wrong here?

 

Error is on line 69

 

 

<?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 different Priceless Stones..<br><br><br> 

<?php
if ($stat[gembag] == 0 ) {

	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> The only way to get a Gem Bag is from a certain person in Silverlake.<br><br>";

Print "[<A href=tricity.php>Back to Town?</a>]"; 


include("footer.php");
exit; } 


else {
		Print "<b>Store Assistant:</b> How are you getting on with that ";
if ($stat[gembag] == 1) { print "<i>Small Gem Bag</i>"; }
if ($stat[gembag] == 2) { print "<i>Gem Bag</i>"; }
print "?<br> Normally you could upgrade that tiny thing! (For a Small Fee) But right now we are out of Stock.<br><br><br>";

Print "[<a href=gemstore.php?view=smith>Visit the Gem Smith</a>]  [<A href=tricity.php>Back to Town</a>]";


if ($view == smith) {
print "<br><br><br><br><b>Gemsmith:</b> I suppose you want me to turn them Puny things into something a little.. Bigger? Well its gonna cost ya <i>250</i> Credits Per Medium and <i>1000</i> Credits per Large. I must warn you, Gem smithing isnt an exact Science, things tend to go wrong.. at your Expense!";

Print "<br><br>[<a href=gemstore.php?view=topaz>Topaz</a>] [<a href=gemstore.php?view=emerald>emeralds</a>] [<a href=gemstore.php?view=ruby>Rubys</a>] [<a href=gemstore.php?view=sapphire>Sapphires</a>]";
if ($stat[shaman] >=  { print "<br><br><a href=gemstore.php?view=work>Work for the Gem Smith</a>"; }

}
if ($view == topaz) {

Print "<br><br><br><br>You currently have <b>$stat[scrystals] Small Topaz</b> and <b>$stat[mcrystals] Medium Topaz</b> in your Possesion.<br><br>What would you like to do?<br><br><br></b>";

Print "[<a href=gemstore.php?step=mtopaz>Make a Medium Topaz</a>]";
if ($stat[gsmith] == 1) { print " [<a href=gemstore.php?step=ltopaz>Make a Large Topaz</a>]"; }
}


if ($step == mtopaz) {

if ($stat[credits] < 250){

Print "<br><br><br>You only have $stat[credits] Credits. Thats not enough!";
include ("footer.php");

}

elseif ($stat[scrystals] < 10){

Print "<br><br><br><br>You only have $stat[scrystals] Topaz. Thats not enough!";

}else{

mysql_query("update players set credits=credits-250 where id=$stat[id]");
mysql_query("update players set scrystals=scrystals-10 where id=$stat[id]");
mysql_query("update players set mcrystals=mcrystals+1 where id=$stat[id]");

Print"<br><br><br><b>Success!!</b>.. You gained <i>1 Medium Topaz</i>!";

}}

if ($step == ltopaz) {

elseif ($stat[credits] < 1000){                                                       // ERROR

Print "<br><br><br>You only have $stat[credits] Credits. Thats not enough!";
include ("footer.php");

}

elseif ($stat[mtopaz] < 10){

Print "<br><br><br><br>You only have $stat[mcrystals] Topaz. Thats not enough!";

}else{

mysql_query("update players set credits=credits-250 where id=$stat[id]");
mysql_query("update players set mcrystals=mcrystals-10 where id=$stat[id]");
mysql_query("update players set lcrystals=lcrystals+1 where id=$stat[id]");

Print"<br><br><br><b>Success!!</b>.. You gained <i>1 Large Crystal</i>!";

}}


if ($view == emerald) {

Print "<br><br><br><br>You currently have <b>$stat[semeralds] Small Emeralds</b> and <b>$stat[memeralds] Medium Emeralds</b> in your Possesion.<br><br>What would you like to do?<br><br><br></b>";

Print "[<a href=gemstore.php?step=memerald>Make a Medium Emeralds</a>]";
if ($stat[gsmith] == 1) { print " [<a href=gemstore.php?step=lemerald>Make a Large Emeralds</a>]"; }
}


if ($step == memerald) {

if ($stat[credits] < 250){

Print "<br><br><br>You only have $stat[credits] Credits. Thats not enough!";
include ("footer.php");

}

elseif ($stat[semeralds] < 10){

Print "<br><br><br><br>You only have $stat[semeralds] Emeralds. Thats not enough!";

}else{

mysql_query("update players set credits=credits-250 where id=$stat[id]");
mysql_query("update players set semeralds=semeralds-10 where id=$stat[id]");
mysql_query("update players set memeralds=memeralds+1 where id=$stat[id]");

Print"<br><br><br><b>Success!!</b>.. You gained <i>1 Medium Emerald</i>!";

}}

if ($step == lemerald) {

if ($stat[credits] < 1000){

Print "<br><br><br>You only have $stat[credits] Credits. Thats not enough!";
include ("footer.php");

}

elseif ($stat[memeralds] < 10){

Print "<br><br><br><br>You only have $stat[memeralds] Emeralds. Thats not enough!";

}else{

mysql_query("update players set credits=credits-250 where id=$stat[id]");
mysql_query("update players set memeralds=memeralds-10 where id=$stat[id]");
mysql_query("update players set lemeralds=lemeralds+1 where id=$stat[id]");

Print"<br><br><br><b>Success!!</b>.. You gained <i>1 Large Emerald</i>!";

}}

if ($view == ruby) {

Print "<br><br><br><br>You currently have <b>$stat[srubys] Small Rubies</b> and <b>$stat[mrubys] Medium Rubiess</b> in your Possesion.<br><br>What would you like to do?<br><br><br></b>";

Print "[<a href=gemstore.php?step=mruby>Make a Medium Rubys</a>]";
if ($stat[gsmith] == 1) { print " [<a href=gemstore.php?step=lruby>Make a Large Rubys</a>]"; }
}


if ($step == mruby) {

if ($stat[credits] < 250){

Print "<br><br><br>You only have $stat[credits] Credits. Thats not enough!";
include ("footer.php");

}

elseif ($stat[srubys] < 10){

Print "<br><br><br><br>You only have $stat[srubys] Rubys. Thats not enough!";

}else{

mysql_query("update players set credits=credits-250 where id=$stat[id]");
mysql_query("update players set srubys=srubys-10 where id=$stat[id]");
mysql_query("update players set mrubys=mrubys+1 where id=$stat[id]");

Print"<br><br><br><b>Success!!</b>.. You gained <i>1 Medium Ruby</i>!";

}}

if ($step == lruby) {

if ($stat[credits] < 1000){

Print "<br><br><br>You only have $stat[credits] Credits. Thats not enough!";
include ("footer.php");

}

elseif ($stat[mrubys] < 10){

Print "<br><br><br><br>You only have $stat[mrubys] Rubys. Thats not enough!";

}else{

mysql_query("update players set credits=credits-250 where id=$stat[id]");
mysql_query("update players set mrubys=mrubys-10 where id=$stat[id]");
mysql_query("update players set lrubys=lrubys+1 where id=$stat[id]");

Print"<br><br><br><b>Success!!</b>.. You gained <i>1 Large Ruby</i>!";

}}



if ($view == sapphire) {

Print "<br><br><br><br>You currently have <b>$stat[ssapphires] Small Sapphires</b> and <b>$stat[msapphires] Medium Sapphires</b> in your Possesion.<br><br>What would you like to do?<br><br><br></b>";

Print "[<a href=gemstore.php?step=msapphire>Make a Medium Sapphires</a>]";
if ($stat[gsmith] == 1) { print " [<a href=gemstore.php?step=lsapphire>Make a Large Sapphires</a>]"; }
}


if ($step == msapphire) {

if ($stat[credits] < 250){

Print "<br><br><br>You only have $stat[credits] Credits. Thats not enough!";
include ("footer.php");

}

elseif ($stat[ssapphires] < 10){

Print "<br><br><br><br>You only have $stat[ssapphires] Sapphires. Thats not enough!";

}else{

mysql_query("update players set credits=credits-250 where id=$stat[id]");
mysql_query("update players set ssapphires=ssapphires-10 where id=$stat[id]");
mysql_query("update players set msapphires=msapphires+1 where id=$stat[id]");

Print"<br><br><br><b>Success!!</b>.. You gained <i>1 Medium Sapphire</i>!";

}}

if ($step == lsapphire) {

if ($stat[credits] < 1000){

Print "<br><br><br>You only have $stat[credits] Credits. Thats not enough!";
include ("footer.php");

}

elseif ($stat[msapphires] < 10){

Print "<br><br><br><br>You only have $stat[msapphires] Sapphires. Thats not enough!";

}else{

mysql_query("update players set credits=credits-250 where id=$stat[id]");
mysql_query("update players set msapphires=msapphires-10 where id=$stat[id]");
mysql_query("update players set lsapphires=lsapphires+1 where id=$stat[id]");

Print"<br><br><br><b>Success!!</b>.. You gained <i>1 Large Sapphire</i>!";

}}


include("footer.php");
exit;
}
?>
<?php include("footer.php"); ?>

 

 

Am i using Else if in an incorect way?

Link to comment
Share on other sites

@poco: It's a brace ;) A bracket is [ (at least that's what I call them).

 

@monk3h: Your code is pretty, uhh, all over the place. Just looking through it at a glance, you've got so much repeated code that you could clean up and make it MUCH easier to read. Also, I can't even follow the if else logic. With so many nested ifs and elses, I really have to wonder if you can even follow it, lol ;) Honestly, you should really look through it and see if you can bring out some of those statements to make it easier.

 

 

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.