Jump to content
MakeWebGames

Jhunter

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Everything posted by Jhunter

  1. Nevermind i solved the problem myself by replacing the "class" folder in my directory
  2. it shows users stats perfectly fine, just shows them all ranked #1 and the only page that i am having issues with is index.php
  3. any one able to help me here??
  4. i am having issues with users all being ranked #1 for stats regardless of their stats any ideas on how to fix this as i dont have a clue where to start?
  5. Thanks Djkanna your knowledge has helped me out and i have solved the problem
  6. i have checked that it is set to auto increment in my database, but oddly when i used a new database and tried a few test registrations it worked perfectly fine, so its not a issue with my files and the database is correct
  7. when player register to my game the user id's are starting at 220+ instead of following the previous id. for example i am id 1 then the next player is id 220, instead of being id 2 .. Any ideas??
  8. i just got my game back online after having a break from coding and running a game for a few years and when i log in now it always says i have been inactive for 5 hours and no matter what i do it doesn't change and it also doesn't show me as logged in.. Any ideas???
  9. Re: [mccode v2] Stock Market. Working + Secured i have tried to add a limit to how many stock you can buy, but every time i try something it doesn't work, is it possible so one can add one then repost the code? Thanks in advance
  10. Re: Stock market limit i took it out when i added it to my game, just to keep file sizes down
  11. Hi every one, i am using code that i found here on CE, and i am wondering if anyone can help me to add a limit on how many stocks you can buy in total. i have spent hours trying to work it out so far, and it is really getting on my nerves. i am not the best coder, so thats why i am asking for your help I was a member on here before i posted this but i forgot all my log in details and the email i used to sign up. my old profile id John1, so i am not a noob that is looking for free help, i will thank you, and i might be able to help you some day. Here is the code   <?php include_once('globals.php'); echo ' <style language="text/css"> .red { color: red; } .green { color: green; } .stock td { border: 1px black solid; } .stock th { border: 1px black solid; } </style> <h2>Stock Market</h2>'; $arrs = array('buy','log','sell','view'); $x = (isset($_GET['trip']) && ctype_alnum($_GET['trip']) && in_array($_GET['trip'], $arrs)) ? trim($_GET['trip']) : FALSE; # False making it not exist making it default page. switch($x) { case 'buy': buy_stock(); break; case 'sell': sell_stock(); break; case 'view': view_stock(); break; case 'log': view_stock_log(); break; default: stock_default(); break; } function view_stock_log() { global $ir,$h; $log = mysql_query("SELECT recordTIME,recordTEXT FROM `stock_records` WHERE `recordUSER` = ".$ir['userid']." ORDER BY `recordTIME` DESC") or die(mysql_error()); if(mysql_num_rows($log) == 0) { echo 'You do not have any log records.'; } else { while($soc = mysql_fetch_assoc($log)) { $time = date('F jS Y g:i:s', $soc['recordTIME']); echo '[b]'.$time.'[/b] '.str_replace('me', 'You', $soc['recordTEXT']).' '; } } } function sell_stock() { global $ir,$h; $id = abs(@intval($_GET['ID'])); $holding = mysql_query("SELECT holdingID,holdingSTOCK,holdingQTY FROM `stock_holdings` WHERE `holdingID` = ".$id." AND `holdingUSER` = ".$ir['userid']) or die(mysql_error()); if(mysql_num_rows($holding) == 0) { echo 'This holding ID does not exist, or you do not own it.'; } else { $soc = mysql_fetch_assoc($holding); $stock = mysql_query("SELECT stockNAME,stockNPRICE FROM `stock_stocks` WHERE `stockID` = ".$soc['holdingSTOCK']) or die(mysql_error()); $stock = mysql_fetch_assoc($stock); $tot = ($stock['stockNPRICE'] * $soc['holdingQTY']); mysql_query("DELETE FROM `stock_holdings` WHERE `holdingID` = ".$soc['holdingID']); mysql_query("INSERT INTO `stock_records` (`recordUSER`,`recordTIME`,`recordTEXT`) VALUES (".$ir['userid'].",unix_timestamp(),'me sold ".$soc['holdingQTY']." of stock ".$stock['stockNAME']." for ".money_formatter($tot)."')") or die(mysql_error()); mysql_query("UPDATE `users` SET `money` = (`money` + ".$tot.") WHERE `userid` = ".$ir['userid']) or die(mysql_error()); echo 'You sold '.number_format($soc['holdingQTY']).' stock of '.$stock['stockNAME'].' for '.money_formatter($tot).'!'; } } function view_stock() { global $ir,$h; $holdings = mysql_query("SELECT holdingID,holdingSTOCK,holdingQTY FROM `stock_holdings` WHERE `holdingUSER` = ".$ir['userid']) or die(mysql_error()); if(mysql_num_rows($holdings) == 0) { echo 'You do not hold any shares in any stocks atm.'; } else { echo ' <table border="0" cellspacing="0" cellpadding="0" class="stocks" width="50%"> <tr> <th>Stock Name</th> <th>Shares</th> <th>Sell Price</th> <th>Sell</th> </tr>'; while($soc = mysql_fetch_assoc($holdings)) { $stock = mysql_query("SELECT stockNAME,stockNPRICE FROM `stock_stocks` WHERE `stockID` = ".$soc['holdingSTOCK']) or die(mysql_error()); $stock = mysql_fetch_assoc($stock); echo ' <tr> <td>'.$stock['stockNAME'].'</td> <td>'.number_format($soc['holdingQTY']).'</td> <td>'.money_formatter($stock['stockNPRICE'] * $soc['holdingQTY']).'</td> <td>[url="'.$_SERVER['PHP_SELF'].'?trip=sell&ID='.$soc['holdingID'].'"]Sell Stock[/url]</td> </tr>'; } echo ' </table>'; } } function buy_stock() { global $ir,$h; $id = abs(@intval($_GET['ID'])); $rows = mysql_query("SELECT stockID FROM `stock_stocks` WHERE `stockID` = ".$id) or die(mysql_error()); if(mysql_num_rows($rows) == 0) { echo 'This stock does not exist.'; exit($h->endpage()); } if(isset($_POST['buy'])) { $amnt = abs(@intval($_POST['amnt'])); $fetch_stock = mysql_query("SELECT stockID,stockNPRICE,stockNAME FROM `stock_stocks` WHERE `stockID` = ".$id) or die(mysql_error()); $stock = mysql_fetch_assoc($fetch_stock); $mprice = ($stock['stockNPRICE'] * $amnt); if($ir['money'] <= $mprice) { echo 'You do not have enough money for this amount of stocks.'; exit($h->endpage()); } $stock_holds = mysql_query("SELECT holdingID FROM `stock_holdings` WHERE `holdingUSER` = ".$ir['userid']." AND `holdingSTOCK` = ".$stock['stockID']) or die(mysql_error()); if(mysql_num_rows($stock_holds)) { mysql_query("UPDATE `stock_holdings` SET `holdingQTY` = (`holdingQTY` + ".$amnt.") WHERE `holdingUSER` = ".$ir['userid']." AND `holdingSTOCK` = ".$stock['stockID']) or die(mysql_error()); } else { mysql_query("INSERT INTO `stock_holdings` (`holdingUSER`,`holdingSTOCK`,`holdingQTY`) VALUES (".$ir['userid'].",".$stock['stockID'].",".$amnt.")") or die(mysql_error()); } mysql_query("UPDATE `users` SET `money` = (`money` - ".$mprice.") WHERE `userid` = ".$ir['userid']); mysql_query("INSERT INTO `stock_records` (`recordUSER`,`recordTIME`,`recordTEXT`) VALUES (".$ir['userid'].",unix_timestamp(),'me bought ".$amnt." of stock ".$stock['stockNAME']." for ".money_formatter($mprice)."')") or die(mysql_error()); echo 'You successfuly bought '.number_format($amnt).' stocks of '.$stock['stockNAME'].'.'; } else { $stock = mysql_query("SELECT stockID,stockNAME,stockCHANGE,stockNPRICE,stockUD,stockOPRICE FROM `stock_stocks` WHERE `stockID` = ".$id) or die(mysql_error()); $stock = mysql_fetch_assoc($stock); $symb = ($stock['stockUD'] == 1) ? '<big>?</big>' : '<big>?</big>'; $class = ($stock['stockUD'] == 1) ? 'green' : 'red'; $blip = ($stock['stockUD'] == 1) ? '+' : '-'; $clor = ($stock['stockOPRICE'] < $soc['stockNPRICE']) ? 'green' : 'red'; echo ' <table border="0" cellspacing="0" width="50%"> <tr> <td>Stock Name</td> <td>'.$stock['stockNAME'].'</td> </tr> <tr> <td>Price Change</td> <td><span class="'.$class.'">'.$blip.' '.money_formatter($stock['stockCHANGE']).' '.$symb.'</span></td> </tr> <tr> <td>Original Price</td> <td>'.money_formatter($stock['stockOPRICE']).'</td> </tr> <tr> <td>Now Price</td> <td>'.money_formatter($stock['stockNPRICE']).'</td> </tr> <tr> <td>Buy Stock</td> <td> <form action="'.$_SERVER['PHP_SELF'].'?trip=buy&ID='.$id.'" method="post"> QTY: <input type="text" name="amnt" value="0" /> <input type="submit" value="Buy" name="buy" /> </form> </td> </tr> </table>'; } } function stock_default() { global $ir,$h; echo ' Here is a list of stocks available along with their price and such. -> [url="'.$_SERVER['PHP_SELF'].'?trip=view"]View your stocks[/url] -> [url="'.$_SERVER['PHP_SELF'].'?trip=log"]View your log[/url] <table border="0" cellspacing="0" cellpadding="0" class="stock" width="70%"> <tr> <th>Stock Name</th> <th>Stock Orig Price</th> <th>Stock Now Price</th> <th>Price Change</th> <th>View</th> </tr>'; $stocks = mysql_query("SELECT stockID,stockNAME,stockOPRICE,stockNPRICE,stockCHANGE,stockUD FROM `stock_stocks`") or die(mysql_error()); if(mysql_num_rows($stocks) == 0) { echo ' <tr> <td align="center" colspan="5">No stocks available</td> </tr> </table>'; exit($h->endpage()); } while($soc = mysql_fetch_assoc($stocks)) { $symb = ($soc['stockUD'] == 1) ? '?' : '?'; $class = ($soc['stockUD'] == 1) ? 'green' : 'red'; $blip = ($soc['stockUD'] == 1) ? '+' : '-'; $clor = ($soc['stockOPRICE'] < $soc['stockNPRICE']) ? 'green' : 'red'; $blic = ($soc['stockOPRICE'] < $soc['stockNPRICE']) ? '+' : '-'; echo ' <tr> <td>'.$soc['stockNAME'].'</td> <td>'.money_formatter($soc['stockOPRICE']).'</td> <td><span class="'.$clor.'">'.$blic.' '.money_formatter($soc['stockNPRICE']).'</span></td> <td><span class="'.$class.'">'.$blip.' '.money_formatter($soc['stockCHANGE']).' '.$symb.'</span></td> <td>[url="'.$_SERVER['PHP_SELF'].'?trip=buy&ID='.$soc['stockID'].'"]Buy Or View[/url]</td> </tr>'; } echo ' </table>'; } $h->endpage(); ?>
×
×
  • Create New...