Click here to Skip to main content
14,880,257 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Seeing as people cant properly read and have to report my last question Even though it was definately clear . So AGAIN. this is a game script im trying to fix the bug on It Works for the most part . The issue with the script its not updating the Users Battle points when its being used to buy the Gems from the Market nor is it updating the Users Gem stats. The only thing it is doing is taking away from the Stock.txt which tells the user how many are in Stock. How do i fix this issue. And if you report this saying its not a question Someone needs to properly read english and have common sense that the question box only allows so much to input which doesnt give me enough room to ask the full question

        if($_COOKIE['edited']) {
        header("Cache-control: private"); //IE 6 Fix
        include "includes/lonconfig.php";
        $title = "Skill Trader Xur";
        include "includes/";
        if(!isset($_COOKIE['edited'])) {
/*       if($playerinfo[status]!=4) {
         echo "sorry we are closed for the moment<br> " ;
       $tendency=sin(date('j')*12)*.1;     //factor to affect prices to generate a ciclycal up/down tendency. I love this, jeje
       //echo "<br>$tendency";

switch ($action)
   case "buy";
      if ($amount!=1) { echo "What are you trying to do ? I didn't offer that deal!<br><br>"; echo "<center><a href=$PHP_SELF>Back</a><br></center>"; break; }
      if ($price!=ceil($stockdata[baseprice][$gem]*(1+$spread)))
         echo "Gem Market prices have changed since last quote. New price is ".ceil($stockdata[baseprice][$gem]*(1+$spread))."<br>";
         echo "Do you want to continue the trade? (prices might change again till you decide)<br><Br>";
         echo "<a href=$PHP_SELF?action=buy&amount=$amount&gem=$gem&price=".ceil($stockdata[baseprice][$gem]*(1+$spread)).">Yes</a> / <a href=$PHP_SELF>No</a><br><br>";

      if ($amount>$stockdata[amount][$gem]) { echo "Sorry, I don't have that much...<br>Come back later, maybe I can get some for you<br><br>"; echo "<center><a href=$PHP_SELF>Back</a><br></center>"; break; }

      if ($playerinfo[battle_points]>=$price*$amount)
         echo "<br>You bought $amount ".$stockdata[gemname][$gem]."(s) for ".$price*$amount."<br><br>";
         echo "<center><a href=$PHP_SELF>Back</a><br></center>";
         mysql_query("update userdb set battle_points=battle_points-".$price*$amount.", ".$stockdata[gemname][$gem]."=".$stockdata[gemname][$gem]."+$amount where id=$playerinfo[id] limit 1");
         mysql_query("INSERT INTO `user_tradelogs` ( `fromid` , `type` , `itemdesc` , `amount` , `amount1` , `fecha` ) VALUES ( '$playerinfo[id]','13', '".$stockdata[gemname][$gem]."', '$amount', '".$price*$amount."', FROM_UNIXTIME(unix_timestamp())+0 )");


      } else echo "You don't have the required battle points to close that operation<br><br><center><a href=$PHP_SELF>Back</a><br></center>";


      echo "You enter the building and the amount of people screaming for buying and selling is amazing, You don't know where to go,";
      echo " Xur approaches you and tells you: \"Welcome to the Gem Market... Pretty busy, uh ?<br><br>What can I do for you?<br><br><br>";
      echo "<table width=100% border=1><tr><th>Item</th><th>Charging</th><th>Buy</th>";
      if ($playerinfo[status]==5) echo "<th>Stock</th>";
      echo "<th colspan=4>In Stock</th></tr>";

      for ($i=1;$i<=3;$i++)
         echo "<tr><td align=center>$gemname</td><td align=center>$buyprice</td>";
         if ($playerinfo[status]==5) echo "<td align=center>$amount</td>";
         echo "<td><a href=$PHP_SELF?action=buy&amount=1&gem=$i&price=$buyprice>Buy 1</a></td>";
         echo "<td>$amount</a></td>";
         echo "</tr>";
      echo "</table>";

      echo "<center><font color=yellow>Battle Points: ($playerinfo[battle_points])</font></center>";
      echo "<br><br><center><a href=stxur.php>Exit Room</a><br></center>";


function loaddata()
   global $tendency;
   $fp = @fopen($filename, "r");
      for ($i=1;$i<=3;$i++)
         $stockdata[gemname][$i] =trim(fgets($fp));
          $stockdata[amount][$i] =(int)trim(fgets($fp));
          $stockdata[baseprice][$i] =(int)(trim(fgets($fp))*(1+$tendency));
          $stockdata[limit][$i] =(int)trim(fgets($fp));
       return $stockdata;

function savedata($stockdata)
   global $tendency;
   $fp = fopen($filename, "w+");
      for ($i=1;$i<=3;$i++)
Updated 3-Sep-15 8:46am
Richard Deeming 3-Sep-15 14:27pm
Starting your question by insulting the UNPAID VOLUNTEERS who answer questions in this site is not going to win you any friends.
Member 11957253 3-Sep-15 14:31pm
well they shouldnt be reporting things saying it doesnt have a question and its not clear when it is clear what the issue is and does ask a question. Not like if i care for points
Richard Deeming 3-Sep-15 14:33pm
It might be clear to you, but it's obviously not clear to everyone else.

Remember, we can't see your screen, access your hard-drive, or read your mind.

Assume that the person reading your question knows nothing about what you're doing, why you're doing it, what problems you're having, etc.
PIEBALDconsult 3-Sep-15 14:57pm
"which doesnt give me enough room to ask the full question"
B.S. So you admit you're not asking the full question? That's a step in the right direction.
Please use Improve question to provide more information about this "Stock.txt" -- is this simply a matter of the file not being updated? And why are you not using a database?
Most problems people encounter can be eliminated by doing things the right way.

I added some partial answer based on the inquirer's previous question, now auto-removed due to our abuse reports.

You are a very new member and I am very much clear that you don't know the rules of asking questions.

When you click "Ask a Question", you land up to a page, where on the right side panel, you can see the below text...

A few simple rules when posting your question.

Be courteous. Everyone here helps because they enjoy helping, not because it's their job.

Have you searched or Googled for a solution?

Be specific! eg "How do I change the dialog colour?" instead of "My code doesn't work. Help?"

Tag your question appropriately.

If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.

Do not remove or empty a message if others have replied.

Your question may be edited or retagged by others. Anything inappropriate will be removed.

Now , tell me which points have you covered in your question?

1 solution

See below the answer to your previous question which has been automatically removed due to abuse report:

Sorry, the question makes little sense. You can change any variable regardless the purpose of this variable. First of all, you should have indicated that the question about the PHP used in a Web site, because PHP can be used in a stand-along way. On a page, you cannot run the script interactively. This is not how Web works. You need to have a page with controls, such as buttons and input controls. You need to take value of controls and send an HTTP request to the same or another page. This another page should handle the request and create HTTP response. In this response, you can re-calculate data.

Now, to send HTTP request, you can use the form element, and you need at a submit button <input type="submit">. You also need the attribute action (URL) and specify the method, such as "post". On server side, you can use PHP $_POST:[^].

Alternatively, to send an HTTP request, you can use JavaScript and AJAX:[^],[^].

In this case, form is not needed. Using the form is much simpler. Please see:[^].

This is all you need.
I must admit that your previous question was much clearer than the present one, so it deserved some answer. Even though the particular problem wasn't clearly pointed out, your post suggested that you had some misunderstanding which can be fixed.

Perhaps understanding of all that may help you to solve the problem you formulated in the present question. But I agree with all the comments to the question you got. You need to explain your problem in much more detail. Your complains about treating your badly are simply inappropriate; I don't event want to discuss it any further.

Perhaps you need to shorted your code as much as possible, but focus on one particular problem and add decent description. If you thing you have a bug, you need to describe precisely how it is manifested. Also, you have to describe your ultimate goals, explain what exactly you are trying to achieve and how.

Sorry for incomplete answer, but I think next step should be yours. I agree with the comment to the question by PIEBALDconsult who mentioned that "That's a step in the right direction".


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900