Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. Isn't that kinda what a Jew is?
  2. I don't see anywhere in your clientside code where you're doing name='text' name='content' in your input tags or passing those name/values to the script.
  3. My guess: You use $title, $text and $id in your update. Those vars don't exist unless you have globals set to ON (which you probably don't, and shouldn't). Since globals are probably set to OFF, posted data will either be in $_GET['varname'] or $_POST['varname'], depending on what method you used (or $_REQUEST['varname'] will have info from either one).
  4. LoL well you may have a tough time getting people to use it. I mean, if someone knows your algorithm they could possibly increase their odds of finding the winning number....maybe. Really depends on how you go about programming in the "odds"
  5. Okay so it looks like from your code that this is your formula per level: $newexp2 = $newlvl2 * $newlvl2 * 1000; So if I were to manually make a chart, xp per level would look like this: level : xp : running total 1 : 1000 : 1000 2 : 4000 : 5000 3 : 9000 : 14000 4 : 16000 : 30000 5 : 25000 : 55000 6 : 36000 : 91000 7 : 49000 : 140000 etc... If that is correct, then as far as merging clans: You say you want to determine the new level by adding up accumulated xp and figuring out what level they should be, based on that, right? Probably a better way but, here's my take: <?php // example clan levels $clanAlevel = 15; $clanBlevel = 10; // get first clan's total xp for ($x = 1; $x <= $clanAlevel; $x++) { $totalA += $x * $x * 1000; } // get second clan's total xp for ($x = 1; $x <= $clanBlevel; $x++) { $totalB += $x * $x * 1000; } // overall total $totalxp = $totalA + $totalB; // init some vars, use temp total var to preserve totalxp $level = 0; $xpleft = $totalxp; // loop until you have no more xp to burn while(true) { // update vars only if there's enough xp to burn if (($xpleft - $xp) > 0) { $level++; // inc to next level $xp = $level * $level * 1000; // find out how much xp it takes to get to next level $xpleft -= $xp; // subtract needed xp from total xp } else { // break out of loop if we run out of xp to burn break; } // end if xp to burn } // end loop echo "new level: $level <br/>"; echo "total xp: $totalxp<br/>"; echo "amount till next level: $xpleft / $xp<br/>"; ?>
  6. I don't think you're really going to find a specific tutorial like this. I mean, the concept is pretty simple: make any kind of algorithm that creates random or pseudo-random numbers/strings, let it run a few times to get a couple codes generated and store them as your "winning" codes. Then just have your script run for each person to get their code. If it happens to generate the same code as one of the ones you stored, you have a winner. I mean in principle, it's like playing the "pick a number from 1-100 and I'll guess it" game, except each person only gets 1 guess. Very simple numeric example: // numbers I decided would be winning numbers. $winners = $array(4,20,82); $num = rand(1,100); if (in_array($num, $winners)) { echo "winner!" } As far as having more than one winner, you would just keep track of the numbers you hand out to people, and check if that number has already been generated yet. Pick another number if it's already been passed out once if you want one winner, or keep track of how many times that number has been generated and skip it after 2 times or 10 times or x times, depending on how many winners you want.
  7. Need more details about your xp structure. For instance, do you have some sort of table of xp per level somewhere? If so, select sum(xp) from xpcharttable where level <= clanAcurrentlvl, do the same for clanB, then $total = $resultA + $resultb; then select level from xpcharttable where xp < $total desc limit 1 (if you want the nearest floored value, swap out < for > for nearest ceil value).
  8. that's because color isn't a valid attribute for < p > you can use the <font color='...' > or <p style='color: ...' >
  9. IMO that article is for people who already understand pagination and want to take it a step further, as far as code flexibility, etc... not to mention that since he's asking about pagination, there's a good possibility that the OOP implementation will probably just make it all the more confusing for him... I suggest you try something more basic, like... http://www.phpfreaks.com/tutorial/basic-pagination (I swear it's not a shameless plug )
  10. ASC is default sort order for ORDER BY so no need to explicitly state it.
  11. sql query would look like this: select column from table order by column as far as explaining the code...what code?
  12. #3: Do you mean God doesn't care as in he doesn't care about anybody/anything? Or do you mean God doesn't care as in he supports both parties and both parties are being retarded children? I think 3) needs to be broken down to those 2 options, making 5 options. And I'm afraid I can't really agree with your assessment of the options. I do not think that most people view themselves or others as 100% good or evil. Nor do I think one always believes their way is the best way. The world just isn't that black and white.
  13. Again, same thing TLG: If I run that script, I cannot guarantee that the next number will be that, by the time I get around to using it. Any number of people can end up doing any number of things that will change that number by then.
  14. Well I mean, you could do it like that (using the correct php syntax, obviously), but I have a feeling you can probably do it in a single query. I guess if you already have a group by in there, maybe you could do it using a JOIN of some kind. But I freely admit I'm no expert on sql. I'll move your thread to the sql forum; you'll have a much better chance of getting a real answer there.
  15. mysql_insert_id() will show the last auto_inc'd id from your personal connection stream. It is dependable in that aspect, yes. But you can't just add 1 to that and assume that the next one is available, because it might not be. Someone else could have gone to a webpage on your site that inserted another row in that time, and thus, the "next available" one would really be mysql_insert_id() +2. Get it?
  16. well there's nothing wrong with the code sasa posted so post your code.
  17. perhaps you're looking to do a GROUP BY?
  18. you forgot the closing ) in your query
  19. No, it might not be. You are assuming that you are the only person accessing and running the script. If you have 10 users, 100, 1000, etc... all doing stuff on your website, you have no guarantee that one (or more) didn't do something that updated your db in that time.
  20. Exactly. Do not sacrifice your code readability for filesize. This is not the 1980's when every byte counted. Shortening your code like that is like the difference between you trying to decide whether to drive down to storeA or to storeB that's next door. You won't even factor into the equation the distance, because in your eyes, it's the same, because it's like, next door.
  21. Main thing I hate about vista is how I get a popup box asking if I'm sure I want to do everything. "Are you sure you want to run this program?" "Are you sure you want to move this file?" "Are you sure you want to open this folder?" "Are you sure you want to allow this connection?" "Are you sure you want to close this program?" "Are you sure you want to get more coffee?" "Are you sure you want to kick me?"
  22. That was the first thing I suggested, which you said didn't work...anyhow, glad you got it working.
  23. Just wanna throw out there that based on my own experience with pagination, it looks like you're redundantly using variables here. I think you probably assign $_GET["p"] to $this->p somewhere earlier, so there's really no point in using $_GET["p"]. Also, I'm assuming that $this->p is supposed to be your current page, but you end up using it as your counter var instead of using $i in your loop. This doesn't technically break your code, but it does make it sort of redundant and confusing...
  24. mysql_connect("localhost", "dink87522_dink", "dink8752_password") or die(mysql_error()); Usually database passwords do not have the prefix attached to them, so unless you physically set your password to be like that, take off the db prefix on your password. And if for some reason your db does that, or you did it yourself, I notice you are have ...22_ on the user but ...2_ on the pw prefix. Perhaps one of these things is the issue?
  25. The error tells you the problem. You cannot have output before starting a session. Make sure there is no output, not even blank lines or whitespace.
×
×
  • 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.