Jump to content

troy_mccormick

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Everything posted by troy_mccormick

  1. Glad it worked out. Be sure to mark this post as solved (bottom left of the page)
  2. You do know that mysqli are PHP functions, right?
  3. Sorry...use this... <?php include('dbconnect.php'); $Query = "SELECT ID, Age, Month, Day, Year, Hometown, State, Graduation, Certificate, Associates, Bachelors, Study, GPA FROM survey WHERE Age = '21'"; $Result = mysqli_query ($db, $Query) or die("<p>Unable to execute the query.</p>" . "<p>Error Code</p>" . mysqli_errno($db) . ": " . mysqli_error($db) . "</p>"); echo "<p>Successfully executed the query.>/p>"; mysqli_close($db); ?>
  4. Don't know if this is it, but give it a shot: <?php include('dbconnect.php'); $Query = "SELECT ID, Age, Month, Day, Year, Hometown, State, Graduation, Certificate, Associates, Bachelors, Study, GPA FROM survey WHERE Age = '21'"; $Result = mysqli_query ($db $Query) or die("<p>Unable to execute the query.</p>" . "<p>Error Code</p>" . mysqli_errno($db) . ": " . mysqli_error($db) . "</p>"); echo "<p>Successfully executed the query.>/p>"; mysqli_close($db); ?>
  5. Hello everyone. I'm not much into OOP or Objects and such, but I'm in a bind attempting to use one. I am attempting to utilize the Texas Hold'em Class (found here) but am having some problems. Below is my code: <?php require_once("inc.cls.cardgame.php"); require_once("inc.cls.pokertexasholdem.php"); Card::$tostring = "small_image"; $objDeck = new Deck(); $objDeck->shuffle(); $card_data = array(); $card_data["DECK"] = array(); array_push($card_data["DECK"], $objDeck); ?> The above returns the value as shown below (one card for all 52 obviously...shortened it up for space here): Card Data PRE: Array ( [DECK] => Array ( [0] => __PHP_Incomplete_Class Object ( [__PHP_Incomplete_Class_Name] => Deck [iNextCard] => 9 [cards] => Array ( [0] => __PHP_Incomplete_Class Object ( [__PHP_Incomplete_Class_Name] => Card [id] => 46 [name] => eight [suit] => spades [value] => 8 [short] => 8 [pth] => 8 ) ) ) ) ) So what am I missing?!?! Thanks, Troy
  6. <?php if ($_POST['distribution_method'] != "CD") { // send email code here } ?>
  7. That script would have to run every second...is that really acceptable? revraz...how would javascript help with this?
  8. In looking over the net, I'm not even finding anything useful... Does anyone have anything on this?? Past experience...experience in a different programming language...anything?!?!
  9. It is possible...I believe you have to write your own function to compare... Here it is: <?php $products = array( array( 'TIR', 'Tires', 100 ), array( 'OIL', 'Oil', 10 ), array( 'SPK', 'Spark Plugs', 4 ) ); function compare($x, $y) { if ( $x[1] == $y[1] ) return 0; else if ( $x[1] < $y[1] ) return -1; else return 1; } usort($products, 'compare'); ?>
  10. No problem. Be sure to click the Problem Solved link at the bottom left of the page...
  11. Should read: <td class="row_description" bgcolor=#ECC69F align="left"><?php $byrndb->current_job($job,type_3); ?></td> (Missing a " before the left section). If that doesn't work, you probably are defining it in your CSS file...
  12. I'm creating a game and I'm trying to accomplish a task that has been plaguing me for some time. Here is what I would like to do: Each user has x amount of time to perform their action. If, after that amount of time, the user hasn't made an action, I would like to automatically perform the action for them. How would I accomplish this with code? What I have tried to do in the past is as follows: 1. On pinging the server, if a player finds a user to have used up the allotted time to perform an action, this user will send the action command automatically. The issue I've run into using this method is that I have received multiple actions for the auto-action player as multiple players are pinging the server every second... 2. Using the last player to have an action submitted to the server, perform the auto-action. The issue with this method is that if the user gets disconnected or whatever after they post their action, the server will be at a stand still. So how would you go about getting this done? Thanks, Troy
  13. Brilliant!!! Thank you very much!! Sometimes I can be a total dunce Thanks again!
  14. Hey Everyone, I'm trying to work this out in my head and I need your help because I stink at math! Here is what I am trying to do: Say I have ten tables with ten people at each table. How would you program something so that as people leave, the tables are kept as close as possible to the same number of people while eliminating tables when possible? This is what I've come up with so far...but I don't think it will help with the eliminating of tables portion: <?php $num_people = 100; $num_tables = 10; $avg_num_people = floor($num_people / $num_tables); $needs_people = array(); $loses_people = array(); foreach($tables AS $table) { if ($table["num_people"] < $avg_people) { $num_people_needed = $avg_people - $table["num_people"]; $needs_people[$table] = $num_people_needed; } elseif ($table["num_people"] > $avg_people) { $num_people_lose = $table["num_people"] - $avg_people; $loses_people[$table] = $num_people_lose; } } ?> Anyone help a crappy math guy out?!?! Thanks!!
  15. Within the switch statement I also have the raise command. It is below. <?php case "raise": $_SESSION["dtp_stat_raise"]++; $new_turn = update_turn($cur_turn, $db); $query1 = "SELECT cur_top_bet, seat_" . $cur_turn . "_cur_stake AS stake, seat_" . $cur_turn . " AS player_id FROM tournament_tables WHERE table_id = " . $_SESSION["dtp_table_id"]; $res1 = $db->query($query1); $row1 = $res1->fetch_assoc(); $player_id = $row1["player_id"]; $raise = $raise_amt; $top_bet = $raise_amt + $row1["stake"]; $query = "UPDATE tournament_tables SET cur_top_bet = $top_bet, last_player_id = $player_id, cur_turn = $new_turn, seat_" . $cur_turn . "_status = 'RAISE', seat_" . $cur_turn . "_stake = seat_" . $cur_turn . "_stake + $raise, seat_" . $cur_turn . "_cur_stake = seat_" . $cur_turn . "_cur_stake + $raise, last_action_dtm = now() WHERE table_id = " . $_SESSION['dtp_table_id']; $res = $db->query($query); $querya = "SELECT tour_id FROM tournament_tables WHERE table_id = " . $_SESSION["dtp_table_id"]; $resa = $db->query($querya); $rowa = $resa->fetch_assoc(); $queryab = "SELECT tour_chips FROM tournaments_entrants WHERE player_id = " . $_SESSION["dtp_player_id"] . " AND tour_id = " . $rowa["tour_id"]; $resab = $db->query($queryab); $rowab = $resab->fetch_assoc(); if ($rowab["tour_chips"] - $raise <= 0) { $query2 = "UPDATE tournaments_entrants SET tour_chips = 0 WHERE player_id = " . $_SESSION["dtp_player_id"] . " AND tour_id = " . $rowa["tour_id"]; } else { $query2 = "UPDATE tournaments_entrants SET tour_chips = tour_chips - $raise WHERE player_id = " . $_SESSION["dtp_player_id"] . " AND tour_id = " . $rowa["tour_id"]; } $res2 = $db->query($query2); $query3 = "SELECT username FROM players WHERE player_id = $player_id"; $res3 = $db->query($query3); $row3 = $res3->fetch_assoc(); $player_name = $row3["username"]; $query2 = "SELECT cur_hand_id FROM tournament_tables WHERE table_id = " . $_SESSION["dtp_table_id"]; $res2 = $db->query($query2); $row2 = $res2->fetch_assoc(); $hand_id = $row2["cur_hand_id"]; if ($rowab["tour_chips"] - $raise <= 0) { // player is all in $queryb = "UPDATE tournament_tables SET seat_" . $cur_turn . "_status = 'ALL_IN' WHERE table_id = " . $_SESSION['dtp_table_id']; $resb = $db->query($queryb); send_table_message($db, "RSSD$player_name raised to \$" . number_format($top_bet, 0, ".", ",") . " and is all in", $_SESSION["dtp_table_id"]); append_hand_history($hand_id, "$player_name raised to \$" . number_format($top_bet, 0, ".", ",") . " and is all in", $db); } else { send_table_message($db, "RSSD$player_name raised to \$" . number_format($top_bet, 0, ".", ","), $_SESSION["dtp_table_id"]); append_hand_history($hand_id, "$player_name raised to \$" . number_format($top_bet, 0, ".", ","), $db); } $querybb = "SELECT * FROM tournament_tables WHERE table_id = " . $_SESSION["dtp_table_id"]; $resbb = $db->query($querybb); $rowbb = $resbb->fetch_assoc(); $update_status = array(); for ($j = 1; $j <= 10; $j++) { if ($rowbb["seat_" . $j] != 0 && $rowbb["seat_" . $j . "_status"] != "FOLD" && $rowbb["seat_" . $j . "_status"] != "ALL_IN") { if ($j == $cur_turn) { $update_status[$j] = $rowbb["seat_" . $j . "_status"]; } else if ($rowbb["seat_" . $j . "_status"] != "FOLD" && $rowbb["seat_" . $j . "_status"] != "ALL_IN") { $update_status[$j] = "WAITING"; } else { $update_status[$j] = $rowbb["seat_" . $j . "_status"]; } } else if ($rowbb["seat_" . $j] != 0) { $update_status[$j] = $rowbb["seat_" . $j . "_status"]; } else { $update_status[$j] = "EMPTY"; } } $query = "UPDATE tournament_tables SET seat_1_status = '" . $update_status[1] . "', seat_2_status = '" . $update_status[2] . "', seat_3_status = '" . $update_status[3] . "', seat_4_status = '" . $update_status[4] . "', seat_5_status = '" . $update_status[5] . "', seat_6_status = '" . $update_status[6] . "', seat_7_status = '" . $update_status[7] . "', seat_8_status = '" . $update_status[8] . "', seat_9_status = '" . $update_status[9] . "', seat_10_status = '" . $update_status[10] . "' WHERE table_id = " . $_SESSION["dtp_table_id"]; $res = $db->query($query); break; ?>
  16. I think I'm going to show some code and ask for direction here. I really can't nail down what it is I need to do to get side pots going... For now let's just take a look at the call function: <?php function post_user_action($action, $cur_turn, $db, $raise_amt = 0) { // db = database connection // action = FOLD | CHECK | CALL | RAISE // cur_turn = SEAT ID of player who is currently up // raise_amt = raise amount if this is a raise...defaults to 0 switch ($action) { case "call": $_SESSION["dtp_stat_call"]++; $new_turn = update_turn($cur_turn, $db); $query1 = "SELECT cur_top_bet, seat_" . $cur_turn . "_cur_stake AS stake, seat_" . $cur_turn . " AS player_id, is_side_pots, side_pots FROM tournament_tables WHERE table_id = " . $_SESSION["dtp_table_id"]; $res1 = $db->query($query1); $row1 = $res1->fetch_assoc(); $is_side_pots = $row1["is_side_pots"]; // is set to Y if there are side pots? $side_pots = $row1["side_pots"]; // contains serialized array of all side pot action $call_amt = $row1["cur_top_bet"] - $row1["stake"]; $player_id = $row1["player_id"]; $querya = "SELECT tour_id FROM tournament_tables WHERE table_id = " . $_SESSION["dtp_table_id"]; $resa = $db->query($querya); $rowa = $resa->fetch_assoc(); $query4 = "SELECT tour_chips FROM tournaments_entrants WHERE player_id = " . $_SESSION["dtp_player_id"] . " AND tour_id = " . $rowa["tour_id"]; $res4 = $db->query($query4); $row4 = $res4->fetch_assoc(); $player_chips = $row4["tour_chips"] - $call_amt; if ($player_chips <= 0) { $query2 = "UPDATE tournaments_entrants SET tour_chips = 0 WHERE player_id = " . $_SESSION["dtp_player_id"] . " AND tour_id = " . $rowa["tour_id"]; } else { $query2 = "UPDATE tournaments_entrants SET tour_chips = tour_chips - $call_amt WHERE player_id = " . $_SESSION["dtp_player_id"] . " AND tour_id = " . $rowa["tour_id"]; } $res2 = $db->query($query2); $query3 = "SELECT username FROM players WHERE player_id = $player_id"; $res3 = $db->query($query3); $row3 = $res3->fetch_assoc(); $player_name = $row3["username"]; $query2 = "SELECT cur_hand_id FROM tournament_tables WHERE table_id = " . $_SESSION["dtp_table_id"]; $res2 = $db->query($query2); $row2 = $res2->fetch_assoc(); $hand_id = $row2["cur_hand_id"]; if ($player_chips <= 0) { $call_amt = $row4["tour_chips"]; $query = "UPDATE tournament_tables SET cur_turn = $new_turn, last_player_id = $player_id, seat_" . $cur_turn . "_status = 'ALL_IN', seat_" . $cur_turn . "_stake = seat_" . $cur_turn . "_stake + $call_amt, seat_" . $cur_turn . "_cur_stake = seat_" . $cur_turn . "_cur_stake + $call_amt, last_action_dtm = now() WHERE table_id = " . $_SESSION['dtp_table_id']; send_table_message($db, "BTSD$player_name called \$" . number_format($call_amt, 0, ".", ",") . " and is all in", $_SESSION["dtp_table_id"]); append_hand_history($hand_id, "$player_name called \$" . number_format($call_amt, 0, ".", ",") . " and is all in", $db); } else { $query = "UPDATE tournament_tables SET cur_turn = $new_turn, last_player_id = $player_id, seat_" . $cur_turn . "_status = 'CALL', seat_" . $cur_turn . "_stake = seat_" . $cur_turn . "_stake + $call_amt, seat_" . $cur_turn . "_cur_stake = seat_" . $cur_turn . "_cur_stake + $call_amt, last_action_dtm = now() WHERE table_id = " . $_SESSION['dtp_table_id']; send_table_message($db, "BTSD$player_name called \$" . number_format($call_amt, 0, ".", ","), $_SESSION["dtp_table_id"]); append_hand_history($hand_id, "$player_name called \$" . number_format($call_amt, 0, ".", ","), $db); } $res = $db->query($query); break; } //check for end of round is_end_of_round($db); } ?> My question to you would be, how would you implement the side pots? I guess I just need the logic help since I can't seem to get it going... Thanks a ton for your help thus far! It's helped get my mind going a little bit...just need another kick and I should be good I bet -Troy
  17. But how do I know when to build an array for the pots? How to I then distribute the money to the winner(s)?
  18. <?php $current_date = date("m/d/Y"); ?> http://us3.php.net/date
  19. Hey Orio, I just tried inserting a numeric value into an INT field with quotes around it, and it worked fine. I really think it's the DESC field name. Unless you put ` around the field name, it would throw this error...
  20. DESC is a MySQL command and shouldn't be used as a field name. Try changing that field name to descrip and you should be good to go...
  21. Ok...I don't have any code yet...but I really don't know where to start. Basically, I'm looking for pseudo code... For those of you that play poker (Texas Hold'em to be specific), if a player goes all in during a tournament and there are multiple callers (or even raisers), there are multiple pots created. What I'm looking to do would be how to track this during a game of poker... I've still got nothing. Even my explanation in words isn't very good... How else can I explain it?? Thanks, -Troy
  22. Hey everyone, As I'm sure most of you are aware from all of my posts related to the PHP side of things, I am attempting to create a poker site using PHP, javascript and such. I have run into a bit of a problem that I would like your help with. When data comes in via the ajax call, I populate the chat box with whatever is coming in. However, in my tests we have found that if there is too much data in this div the application slows down tremendously. Is there a way to trim lines using javascript? Thanks you in advance, Troy
  23. What that means is that in your PHP.ini file you have not setup your mail server. I'm assuming that you are getting this error while running the code on your local machine. If not, this is something your host will most likely have to change for you. Read more about it on the mail() function page of the manual.
  24. I guess you could always just try to pull down the index page using the file() function... I don't know if that is the most secure way of doing it...but I think it would work...
  25. Shortest answer ever: Yes. Read up on mkdir() Enjoy!
×
×
  • 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.