Gucci Mane Posted November 18, 2009 Posted November 18, 2009 I tried coverting my Cyber Bank to a Crystal Bank. I just started learning PHP. I know HTML/CSS. So I figured I would try some hands on stuff :) This is the error I get: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/******/public_html/crystalbank.php on line 73 This is the script: <?php include "globals.php"; print "<h3>Crystal Bank</h3>"; if($ir['crystals']>-1) { switch($_GET['action']) { case "deposit": deposit(); break; case "withdraw": withdraw(); break; default: index(); break; } } else { if(isset($_GET['buy'])) { if($ir['money']>50000) { echo "Congratulations, you bought a Crystal Bank account for \$50,000! [url='crystalbank.php']Start using my account[/url]"; $db->query("UPDATE users SET money=money-50000,crystals=0 WHERE userid=$userid"); } else { echo "You do not have enough money to open an account. [url='explore.php']Back to town...[/url]"; } } else { echo "Open a Crystal Bank account today, just \$50,000! [url='crystalbank.php?buy']> Yes, sign me up![/url]"; } } function index() { global $db,$ir,$c,$userid,$h; echo "\n[b]You currently have \${$ir['crystals']} in the bank.[/b] At the end of each day, your bank balance will go up by 7%. <table width='75%' border='2'> <tr> <td width='50%'>[b]Deposit Crystals[/b] It will cost you 15% of the crystals you deposit, rounded up. The maximum fee is \30 Crystals.<form action='crystalbank.php?action=deposit' method='post'> Amount: <input type='text' name='deposit' value='{$ir['crystals']}' /> <input type='submit' value='Deposit' /></form></td> <td> [b]Withdraw Crystals[/b] It will cost you 7.5% of the crystals you withdraw, rounded up. The maximum fee is \30 crystals.<form action='crystalbank.php?action=withdraw' method='post'> Amount: <input type='text' name='withdraw' value='{$ir['crystals']}' /> <input type='submit' value='Withdraw' /></form></td> </tr> </table>"; } function deposit() { global $db,$ir,$c,$userid,$h; $_POST['deposit']=abs((int) $_POST['deposit']); if($_POST['deposit'] > $ir['crystals']) { echo "You do not have enough crystals to deposit this amount."; } else { $fee=ceil($_POST['deposit']*3/100); if($fee > 30) { $fee=30; } $gain=$_POST['deposit']-$fee; $ir['crystals']+=$gain; $db->query("UPDATE users SET crystals=crystals+$gain, crystals=crystals-{$_POST['deposit']} where userid=$userid"); echo "You hand over \{$_POST['deposit']}crystals to be deposited, after the fee is taken (\$$fee), \$$gain is added to your account. [b]You now have \{$ir['crystals']} in the crystal Bank.[/b] [url='crystalbank.php']> Back[/url]"; } } function withdraw() { global db,$ir,$c,$userid,$h; $_POST['withdraw']=abs((int) $_POST['withdraw']); if($_POST['withdraw'] > $ir['crystals']) { echo "You do not have enough banked crystals to withdraw this amount."; } else { $fee=ceil($_POST['withdraw']*3/1000); if($fee > 300000) { $fee=300000; } $gain=$_POST['withdraw']-$fee; $ir['crystals']-=$gain; $db->query("UPDATE users SET crystals=crystalsmoney=money+$gain where userid=$userid"); echo "You ask to withdraw $gain, the teller hands it over after she takes the bank fees. [b]You now have \${$ir['crystals']} in the Crystal Bank.[/b] [url='crystalbank.php']> Back[/url]"; } } $h->endpage(); ?> Quote
seanybob Posted November 18, 2009 Posted November 18, 2009 $fee=ceil($_POST['deposit']*3/100); if($fee > 30) { $fee=30; } $gain=$_POST['deposit']-$fee; $ir['crystals']+=$gain; $db->query("UPDATE users SET crystals=crystals+$gain, crystals=crystals-{$_POST['deposit']} where userid=$userid"); echo "You hand over {$_POST['deposit']} crystals to be deposited, after the fee is taken ($fee crystals), $gain crystals is added to your account. [b]You now have {$ir['crystals']} in the crystal Bank.[/b] [url='crystalbank.php']> Back[/url]"; You had a couple extra slash marks in there that you didn't need (they are used to escape the $ sign for money, not crystals). However, there are several other problems with your code... I'll let you try to sort them out first and learn from it, but post here again if you have any troubles. Quote
Gucci Mane Posted November 18, 2009 Author Posted November 18, 2009 Advice Whats the best way to learn coding from other mods?? Quote
Uridium Posted November 19, 2009 Posted November 19, 2009 Gucci without helping too much so you may fix this yourself... remember your script is working with crystals and not money so any relevance to the $ needs to be carefully looked at we use \$ so the script doesnt get confused with a function. So that would be a good place to start... Quote
Gucci Mane Posted November 19, 2009 Author Posted November 19, 2009 Ok man thanks ill tyr it later thanks. any other tips? Quote
Uridium Posted November 19, 2009 Posted November 19, 2009 Your error message report an error on line 74 which is echo "You hand over \{$_POST['deposit']}crystals to be deposited, Remeber i mentioned stray \$ cause the $ to appear as a word well \ by itself can uncomment out a line so just for this case remove the \ from this line Quote
Gucci Mane Posted November 19, 2009 Author Posted November 19, 2009 ok ill try it lol Whats a good way to learn PHP from other mods? Quote
Zero-Affect Posted November 22, 2009 Posted November 22, 2009 Gucci Mane, Search Free Plugins section of the forum and study peoples ways of using functions strings variables and so forth then just simply test something of your own. Probably best to take a part time course in Web languages at your local college if your really interested. Quote
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.