Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. That's the syntax for an UPDATE query, not an INSERT query.
  2. That's the same as: $str = '1.46'; if(intval($str * 10) == $str * 10) { // it is }
  3. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=342341.0
  4. If we made it to "step 2", then we know that one of the following cards was selected: BK, BQ, RJ, B5, BA, RA, or B9. In total that's 14 cards. That's where the /14 comes from. Now we need see how many of those aren't RJ or B5 or B9 to calculate P(RJ or B5 or B9 not in first draw). So that means it can be BK, BQ, BA, or RA. There are 8 of those in the deck, so 8/14.
  5. Continuing where I left off.. For P(2) we have: P(2) = P(RJ or B5 or B9 not in first draw) * 10/51 + P(RJ or B5 or B9 in first draw) * 9/51 Now we need to calculate P(RJ or B5 or B9 not in first draw) and P(RJ or B5 or B9 in first draw). P(RJ or B5 or B9 not in first draw) = 8/14 P(RJ or B5 or B9 in first draw) = 6/14 So we get: P(2) = 8/14 * 10/51 + 6/14 * 9/51 = 67/357 So, so far we have P(1) = 14/52; P(2) = 67/357. So the probability that the first two steps happen successively is: = P(1) * P(2) = 6/14 * 67/357 = 67/833. I don't have time to continue now but hopefully that at least helps. I don't actually have much experience with probability, so it may look more complicated than it actually is, and it might be hard to follow my train of thought. You just need to know a few simple rules (that are more or less common sense anyway) and apply them (e.g. Probability of something happening = that outcome / total possible outcomes). It's a bit involved, but it all really stems from that simple idea.
  6. It's late, and it's been a long day, so forgive me if I make a mistake.. my brain is half asleep. Let P(k) be the probably of the kth card drawn as we want. So then, we want to find , or the probability of the 13 successive events. We define the two sets as A and B. I use the notation: B4, for example to mean black 4, BK means black king, etc.. P(1) - This is the simple one, the first card just has to be any of the first 12 cards we're looking for. However, we have to be careful because there are two extra cards in the deck: the black ace and red ace. There are two of each of those, but we're only looking for one of each. P(1) = P(any card in A or B) = P(BK ∪ BQ ∪ RJ ∪ B5 ∪ BA ∪ RA ∪ B9) = 14/52 P(2) - This is where it starts to get a little more complicated, because there are multiple cases to account for. The RJ, B5 and B9 are needed in both sets, so we need to keep this in mind. For example, if in the first pick we drew a BK, because the second draw wouldn't require a BK, that wouldn't affect the probability of that case; however, if we drew a RJ, the second draw also needs that, so we need to keep that in mind. If RJ or B5 or B9 are not in the first draw, then the probability of getting the next card we want is 10/51. Otherwise, it would be 9/51: P(2) = P(RJ or B5 or B9 not in first draw) * 10/51 + P(RJ or B5 or B9 in first draw) * 9/51 -- Those are the first two, it gets longer more tedious to compute the further you do down because there are more possible scenarios to account for. Hopefully that can get you started, but maybe I didn't explain well enough. I'll get some sleep and maybe continue with the problem later. Good luck.
  7. Does set 1 have to Go to person 1, or could who gets which set be switched? Also, is the "1 off" the next card after both people have 6 cards?
  8. Does the order of the sets matter (e.g. set 2 before set 1). Does the order of the cards within a set matter?
  9. A quick glance shows that you're forgetting to pass the data parameter into the callback, success: function() { $('#ajaxDiv').html(data); } Should be: success: function(data) { $('#ajaxDiv').html(data); }
  10. Well look at your code: <?php $core = new core; $parent = new parents; $parent->core =& $core; ?> The constructor is called when the object is instantiated here: $parent = new parents; But you're not assigning the core property until the next line: $parent->core =& $core; You can't access the methods of the object in the constructor because at that point core isn't a member of parent. One possible alternative is to pass $core into the constructor of $parent and assign it there before you use it, but it depends on what you're trying to accomplish.
  11. Oh, are you saying that you can't do $this->core inside of parent's constructor?
  12. Oh sorry, I misinterpreted what you meant. Yeah, we don't even know what your intending output is, so we can't help you fix it.
  13. The OP doesn't want to loop through the same results multiple times, and the loops use different MySQL results, so that shouldn't be an issue. It will be looped again if there are multiple results.
  14. What you want to do is create another file that will serve the images. That file will fetch the image from the database, and output the data along with the appropriate header. Then you can use it like: <img src="image.php?id=5" alt="" /> For example, where image.php is the file that serves the image from the database.
  15. There's nothing inherently flawed with nested while loops, so the problem is with your code, but you're not giving us enough context to see what the issue is. Try posting several lines above that.
  16. Extending a class in OOP has a very precise meaning, and that's not what you're doing here, so be careful with the terminology. You shouldn't have to call a constructor twice. If you need to do something similar, you can do this: class SomeClass { public function __construct() { $this->init(); } public function init() { } } Then you can use init().
  17. PCREs require delimiters. For example, /[a-d]/, or ~[a-d]~.
  18. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=341968.0
  19. This line: if (strlen($password) < 5 || > strlen($password) 26) { It should be strlen($password) > 26 And also this line: if ($password == $userName { You're missing a parenthesis.
  20. One way to accomplish this is to store the files in question outside of your document root so that they are not directly accessible. Then create a PHP file to serve the files. Once you have that all you need to check if the user is logged in before you serve the file. You can look into readfile.
  21. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=341963.0
  22. Try this: $_POST = array_map(array($this, 'parent::scrub'), $_POST);
  23. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=341844.0
×
×
  • 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.