OK, I have it working. Sort of.
I changed it to:
OUT;
if($upgrade == "Y") { return "upgrade"; }
{
print"<a href=upgrade.php>[upgrade]</a>";
}
Now the code works and prints the [upgrade] button/option.
BUT, it also works if I do this:
<img src=greenbar.png width=$hpperc height=10><img src=redbar.png width=$hpopp height=10>
<a href=upgrade.php>[upgrade]</a>
<hr />
OUT;
(totally removed the if($upgrade == "Y") { return "upgrade"; }
So, it seems the problem is the if($upgrade == "Y") is not working the way it should, as the upgrade button is always there, and returns the statement "you don't have enough experience to upgrade" when you don't have enough exp. If you do have the required exp, it upgrades you, but I thought the idea of the statement was to only print the option IF there was enough experience to upgrade.