Jump to content

NICON

Members
  • Content Count

    40
  • Joined

  • Last visited

Community Reputation

0 Neutral

About NICON

  • Rank
    Member
  1. Those 2 id's are determined by a global variable $user->id and a defined variable earlier in the script $g defined in a class. The $g is defined by $_POST actually. So the user's id is taken from who is submitting the form and the $_POST variable is defined through the class using the id when the user hits submit.
  2. Okay that makes sense for sure. Thats the table being queried. When I use the following: SELECT COUNT(id) c, id, owner FROM cities WHERE owner IN ('21', '37') AND available = 0 My results are: When I use this: SELECT COUNT(id) c, id, owner FROM cities WHERE owner IN ('21', '37') AND available = 0 GROUP BY id, owner My results are: I want my count in this case to be 2 (my count will always be 0, 1, or 2 depending on how many rows are populated with the 21 or 37 value). These values change based on the person using this page and the owner being checked. I also want the 2 results for id and owner that I get when using the GROUP BY. So count here should be 2 and I should get output for the id and owner for both results. Hope that clears it up.
  3. I want COUNT() to be the total number of sets and the query to return the results of id and owner for each of the result sets.
  4. To explain better I am searching this table for results. There may be 100 rows in this table and never will there be more than 2 results. Some cases there will be 1 or 2 results. If there are only 1 result I want it to do this and if there are 2 results and the current result is not what I am looking for I have it loop again until I get that result. The issue I was having with the old code was that it would only loop once because it was only fetching the single row despite the fact that the count was in fact picking up 2 rows. The count has always been correct it was just not fetching the result properly.
  5. Correct me if I am wrong but by grouping wont that mean that my count will only be one unless a duplicate entry is found. In this case my query will only result in 0, 1 or 2 and will never be more than that. So now the query will give me both results as I wanted but the count is also only one even though 2 results are found.
  6. SELECT COUNT(id) c, id, owner FROM cities WHERE owner IN ('21', '37') AND available = 0 So the result for the count is 2 as shown but the result is only showing the first of the 2 rows. I have looked far and wide and cant seem to pin down why my result is incorrect. Thanks in advance for your help.
  7. I am assuming that is what is being done. I of coarse dont have the end user code or what exactly they are bookmarking but its running 100's of pages at once. I will dig into this throttling that you are speaking of and see how I can implement it into the code. Thanks!
  8. As I stated before its not a single bookmark its opening hundreds of bookmarks at once is the issue. Allowing someone to click this link on 100's of pages at once is what is unfair. The flow is appropriate but allowing someone to click so many links with one click is the issue.
  9. I agree it this site was just a general site that an every day to day user would join then I would agree 100%. However this site requires the user to be logged in to see these pages. On this page are roughly 80 different links going to different places. The idea here is to allow the user plenty of freedom and access to other parts of the site simultaneously. But this one link is integral to the site. Many users are trying to access this same link. But this one specific user has an unfair advantage because his bookmarks allow them to use this link on several users pages. The link is intended to be used and not a mass tab execution through bookmarks.
  10. So the page I am referring to is dynamic. And its only dynamic by one integer. So ?ID=1 or ?ID=2 etc.... I've been to similar pages before where the developer of that site has forced people to use the links and has essentially broken all bookmarks using that dynamic URL. I am unsure how he did it but I know that it was done. I am wanting to do something similar but without copying exactly what he did. Its not an issue of the script running its just an issue of this person is circumventing the process and creating an advantage over others by bookmarking these pages.
  11. I am trying to find a workaround for people using bookmarks and executing them simultaneously forcing a script to run thousands of times in just a second. Is there a way I can implement a token or a short bit of javascript that would force the user to use the link vs bookmarked URL pages? Sorry if I am being vague here but its really causing me issues having people doing this on my site.
  12. Ignore the above I missed the variable being carried through. $x vs $no... Below is what it should have been. Thanks so much i think this got it working correctly. <?php $no = 400; $a = 0; for ($x = 1; $x < $no; ++$x) { if ($x < 200) { $a += $x * round($x + 5 * pow(4, ($x / 300))); } elseif ($x < 400) { $a += $x * round($x + 7 * pow(4, ($x / 290))); } elseif ($x < 600) { $a += $x * round($x + 11 * pow(4, ($x / 280))); } elseif ($x < 800) { $a += $x * round($x + 19 * pow(4, ($x / 270))); } elseif ($x < 1000) { $a += $x * round($x + 35 * pow(4, ($x / 260))); } else { $a += $x * round($x + 67 * pow(4, ($x / 250))); } echo round($a / 1.25); } ?>
  13. This is what I come up with base on your recomendation. However the numbers still get lost after 200: <?php $no = 201; $a = 0; for ($x = 1; $x < $no; ++$x) { if ($no < 201) { $a += $x * round($x + 5 * pow(4, ($x / 300))); } elseif ($no < 401) { $a += $x * round($x + 7 * pow(4, ($x / 290))); } elseif ($no < 601) { $a += $x * round($x + 11 * pow(4, ($x / 280))); } elseif ($no < 801) { $a += $x * round($x + 19 * pow(4, ($x / 270))); } elseif ($no < 1001) { $a += $x * round($x + 35 * pow(4, ($x / 260))); } else { $a += $x * round($x + 67 * pow(4, ($x / 250))); } echo round($a / 1.25); } ?> Below are the values for 199 through 210. Running the above gets me 2367891 vs 2302679. Something is odd here and why its running an extra time through the previous condition is perplexing to me. All the values are identical up to and including 200 using this code.
  14. So I have a very simple for loop that I am populating a list with levels and exp required to achieve the next level. I have been using a sandbox to test my output and have also created an excel sheet to replicate the data to verify the content. This code was not mine from the beginning and in creating the spreadsheet I discovered the flaw. Below is the code I am trying to fix: function experience($L, $pres = 0) { $a = 0; $end = 0; for ($x = 1; $x < $L; ++$x) { $a += $x * round($x + 5 * pow(4, ($x / 300))); } if ($x > 199) { $a += $x * round($x + 7 * pow(4, ($x / 290))); } if ($x > 399) { $a += $x * round($x + 11 * pow(4, ($x / 280))); } if ($x > 599) { $a += $x * round($x + 19 * pow(4, ($x / 270))); } if ($x > 799) { $a += $x * round($x + 35 * pow(4, ($x / 260))); } if ($x > 999) { $a += $x * round($x + 67 * pow(4, ($x / 250))); } return round($a / 1.25); } Below is the troubleshooting I am attempting to do (Modified and simplified for and while loop): //for loop $no = 200; $a = 0; for ($x = 1; $x < $no; ++$x) { $a += $x + 1; } if ($no > 199) { $a += $x + 2; } echo $a; //while loop $no = 200; $a = 0; $x = 1; while (($x - 1) < $no) { $a += $x * round($x + 5 * pow(4, ($x / 300))); $x++; if ($x > 199) { $a += $x * round($x + 7 * pow(4, ($x / 290))); } } echo $a; Upon request I can also provide snipets of the excel sheet. So the gist of what the issue I am having is this. Between level 199 and 200 the iteration of the loop is running one extra time through the initial formula. As you can tell at level 200, 400, 600, 800 and 1000 I want this formula to change so that it simplifies the amount of exp required to achieve the next level. I can not for the life of me figure out how to restrict the loop while still allowing the values 200 up to run through it for the first 199 iterations. The output I should get from the primary code for levels 199 through 201 are as follows: 199 = 200 = 201 = At level 199 I am good but for whatever reason it runs one additional iteration at the level 1-199 formula and then moves on to the 200 level formula messing up the values. Any and all help is much appreciated. I am a novice hobbyist at best and have been doing this for many, many years now but sometimes I get stumped. I chalk it up to lack of proper training and time to really be serious with it. Thanks in advance....NICON
  15. if ($number <= 9 || $yourhp <= 0) { $log[] = $number . ":&nbsp;" . $defender->formattedname . " hit you for " . prettynum($damage) . " damage using their " . $defender->weaponname . ". <br />"; } if ($number <= 9 || $theirhp <= 0) { $log[] = $number . ":&nbsp;" . $defender->formattedname . " hit you for " . prettynum($damage) . " damage using their " . $defender->weaponname . ". <br />"; } Adding these 2 if statements in limits the amount of data stored in the array... Which may have been the issue all along just way to much info in the array? I was getting a 500 error because of it.
×
×
  • 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.