Jump to content

Jessica

Staff Alumni
  • Posts

    8,968
  • Joined

  • Last visited

  • Days Won

    41

Everything posted by Jessica

  1. I have a function for part of my blackjack game I am writing. There is an array $cards[] in the file cards.php. Here is the part of the function that is causing trouble in game_functions.php [code]function bj_points($bj_info){     include_once('cards.php');     $points     = array();     $dealer     = $bj_info['dealer'];     $userhand = $bj_info['userhand'];     $dpoints     = 0;     $dpoints2 = 0;     $ppoints     = 0;     $ppoints2 = 0;     $temp = strlen($dealer);     for($i=0; $i<=$temp; $i=$i+2){         $card         = substr($dealer, 0, 2);;         $dealer_hand[] = $card;         $dealer         = substr($dealer, 2, strlen($dealer));         $cardkey         = array_search($card, $cards); //<-- line 413         if($values[$cardkey] == 1){             $dpoints     += 1;             $dpoints2 = $dpoints;             $dpoints2 += 11;         }else{             if($bj_info['stage'] < 3){                 $dpoints = $values[$cardkey];             }else{                 $dpoints += $values[$cardkey];             }         }     }     }[/code] And this is the error I get [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: array_search(): Wrong datatype for second argument in (snip)html/games/game_functions.php on line 413[/quote] Help? I tried adding global $cards; to the function but it didn't help.
  2. SOLVED thanks to Google Groups & comp.lang.javascript. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]1. For the gender select, you don't define a value. So, instead of referencing: document.signup.gender.options[...].value You should reference: document.signup.gender.options[...].text 2. @ line 219 of rendered code: <option select>male</option> This should be either: <option selected>male</option> Or (even better and complient with the specified doctype): <option selected="selected">male</option> 3. @ line 206 of rendered code: <img src="'.$url.'hat_'.$hat.'.gif" (unparsed PHP code) [/quote]
  3. Page: [a href=\"http://www.doublooncove.com/signup.php\" target=\"_blank\"]Game Sign Up Form[/a] Problem: In Firefox, the changes work fine. In IE, the images just disappear, and there is a broken image. The images are THERE. Some are blank images (like placeholders, since the male character is shirtless, his shirt is blank). But they do exist. Here is a sample of the code, there are several of these functions but they're all the same just different parts. [code]function change_gender(){     if(!document.images){         return     }else{     document.images.bodygender.src="http://www.doublooncove.com/images/pirates/" + document.signup.gender.options[document.signup.gender.selectedIndex].value + "/" + document.signup.gender.options[document.signup.gender.selectedIndex].value + ".gif"          document.images.hairback.src="http://www.doublooncove.com/images/pirates/" + document.signup.gender.options[document.signup.gender.selectedIndex].value + "/hair/" + document.signup.hair.options[document.signup.hair.selectedIndex].value + "/hair_" + document.signup.hair.options[document.signup.hair.selectedIndex].value + "_" + document.signup.hair_color.options[document.signup.hair_color.selectedIndex].value + "_back.gif"                  document.images.hairfront.src="http://www.doublooncove.com/images/pirates/" + document.signup.gender.options[document.signup.gender.selectedIndex].value + "/hair/" + document.signup.hair.options[document.signup.hair.selectedIndex].value + "/hair_" + document.signup.hair.options[document.signup.hair.selectedIndex].value + "_" + document.signup.hair_color.options[document.signup.hair_color.selectedIndex].value + "_front.gif"     *snip*     } }[/code] [code] <td><b>Gender:</b></td> <td>     <select size="1" name="gender" onChange="change_gender()">     <?     if($info['gender'] == 'female'){         print '<option select>female</option>';         print '<option>male</option>';     }else{         print '<option select>male</option>';         print '<option>female</option>';     }     ?>     </select> </td>[/code] Any ideas?
  4. [code]<div id="clock"> <script language="javascript">   // Get the server time and GMT offset   var server_offset = <? print(date('Z')); ?>;   var server_time = <? print(time()); ?>;   // The clock DIV   var clock = document.getElementById("clock");   // Get the client GMT offset   var client_offset = new Date();   client_offset = client_offset.getTimezoneOffset() / 60;   // Get the appropriately mapped time   var client_time = server_time;   var clock = document.getElementById("clock");   var client_time = server_time;   function js_clock() {     var date_time = new Date((client_time * 1000));     var date      = date_time.getDate();     var month     = date_time.getMonth() + 1;     var year      = date_time.getFullYear();     var hours     = date_time.getHours()+(client_offset-5);     var minutes   = date_time.getMinutes();     var seconds   = date_time.getSeconds();     var suffix    = "AM";     if(hours > 11){         suffix = "PM";         hours = hours - 12;     }     if(hours == 0){         hours = 12;     }     if(hours < 10){         hours = "0" + hours;     }     if(minutes < 10){         minutes = "0" + minutes;     }     if(seconds < 10){         seconds = "0" + seconds;     }     if(month < 10){         month = "0" + month;     }     clock.innerHTML = hours + ":" + minutes + ":" + seconds + " " + suffix;     client_time++;     setTimeout("js_clock()", 1000);         }                 js_clock(); </script> </div>[/code] This is what I got, I checked it by setting my computer timezone differently and it works.
  5. [!--quoteo(post=373554:date=May 13 2006, 01:21 PM:name=eXtaZa)--][div class=\'quotetop\']QUOTE(eXtaZa @ May 13 2006, 01:21 PM) [snapback]373554[/snapback][/div][div class=\'quotemain\'][!--quotec--] You can use the date funtion in php, its by the server time and its much more simple... [/quote] but then the clock isn't dynamic.
  6. [!--quoteo(post=373545:date=May 13 2006, 12:32 PM:name=eXtaZa)--][div class=\'quotetop\']QUOTE(eXtaZa @ May 13 2006, 12:32 PM) [snapback]373545[/snapback][/div][div class=\'quotemain\'][!--quotec--] I think that by the user's computer time... [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] But I don't know exacly... [/quote] yeah..it is the user's. My fiance is trying to help me get it to display server time, or at least just the same time for everyone, we want it in CST. :(
  7. That'll do the trick! Is it going off my server time or the user's computer's time?
  8. I've been trying to find a javascript clock, and all the ones I find by googling are in forms in the input field type. Does anyone know how I would do this without putting it in a form? Thanks
  9. [b]EDIT: [/b]Uhm, I have no idea what happened. It wasn't working for hours last night. I looked again just now and it works. So...if anyone wants to take a gander, feel free, but it's working now so I'm good. Sorry! I have [a href=\"http://doublooncove.net/stalls.txt\" target=\"_blank\"]this php code[/a] saved as stalls.php. I need to display it on several different pages, so I am including it in them. Here is one page it is included in: [code]session_start(); include_once('../functions.php'); validate_user(); include_once('../loc_names.php'); $location = $session_loc_id; if($location != 1){     header('Location: http://www.doublooncove.net/explore');     die(); } include_once('../header.php'); ?> <h1>Top of the Third Pier</h1> <p> The infamous third pier of the port of the emerald coast lives up to its reputation. A few gangs of burly sailors shift cargo up the pier while a shifty-eyed man whispers quietly with their stern captain. A weasely merchant tries to sell you a parrot that appears to actually be dead, and you feel a hand tug at your pockets as an old beggar jostles into you. What a great place to do business!</p> <? include_once('../stalls.php'); include_once('../footer.php');[/code] The problem is when I view just stalls.php it prints the variables title, till, etc. When I view it in this page, it prints everything but the variables. What is wrong?
  10. [!--quoteo(post=366104:date=Apr 18 2006, 01:10 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 18 2006, 01:10 PM) [snapback]366104[/snapback][/div][div class=\'quotemain\'][!--quotec--] It works fine for me. Whats the problem? If I selected 2 from the menu na orange square appears in the brown box and if I select 1 a red box apears in the brown box. [/quote] Someone else already helped me on another forum, was just about to come delete this ;)
  11. SOLVED!! [a href=\"http://doublooncove.net/test.txt\" target=\"_blank\"]Here is the code[/a] [a href=\"http://doublooncove.net/test.php\" target=\"_blank\"]Here is the test page[/a] The image should change to 1 or 2 when you click on 1 or 2 in the drop down. I have tried onBlur, onClick, onChange and onFocus. What should I do?
  12. Sorry, maybe I didn't ask clearly enough. I know there are advantages to using OOP, but I don't understand what it is. It's classes & functions, having objects...but I don't know how you would write PHP without those things.
  13. I'm having trouble understanding the concept of OOP and non-OOP programming. I was taught that PHP is an OOP language, yet someone is telling me they can code PHP without it being OOP. Can someone please explain OOP in an easy to understand way, and if PHP can be non OOP, an example?
  14. [!--quoteo(post=361729:date=Apr 4 2006, 04:03 PM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ Apr 4 2006, 04:03 PM) [snapback]361729[/snapback][/div][div class=\'quotemain\'][!--quotec--] hey, if someone wants a percentage to start at 15 and end at 35, who am i to argue? [/quote] I do have a reason ;) I promise, I'm not totally insane.
  15. [!--quoteo(post=361708:date=Apr 4 2006, 03:17 PM:name=Dan R.)--][div class=\'quotetop\']QUOTE(Dan R. @ Apr 4 2006, 03:17 PM) [snapback]361708[/snapback][/div][div class=\'quotemain\'][!--quotec--] But it would not work if you wanted 1/10 to be 15%, it would have made 1/10 equal to 17% (15 + (1/10 *20)) But I see now that you wanted 0 to be 15% - did you edit that or was it just Mark who started all this 1/10 = 15% nonsense ;) [/quote] That was my fault, I fixed it to reflect it. I've got it working perfectly now. I meant when A=0, not a=1 :) Sorry!
  16. Actually the way redbullmarky posted worked perfectly. Here's what I get now when B = 7 0/7: 15 1/7: 17 2/7: 20 3/7: 23 4/7: 26 5/7: 29 6/7: 32 7/7: 35
  17. [!--quoteo(post=361633:date=Apr 4 2006, 01:01 PM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ Apr 4 2006, 01:01 PM) [snapback]361633[/snapback][/div][div class=\'quotemain\'][!--quotec--] yes. [/quote] Thaaank you :)
  18. [!--quoteo(post=361630:date=Apr 4 2006, 12:57 PM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ Apr 4 2006, 12:57 PM) [snapback]361630[/snapback][/div][div class=\'quotemain\'][!--quotec--] assuming that your examples are not shown with the results you expect, then: [code] $percent = ($a/$b)*35; [/code] would give you a "percentage" with 35 as the top value, as the normal way to work out percent is: [code] $percent = ($pizza_slice_size/$pizza_full_size)*100; [/code] [/quote] So if I want only between 15-35, I could do: $percent = ($a/$b)*20; and add 15% right?
  19. [!--quoteo(post=361626:date=Apr 4 2006, 12:48 PM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ Apr 4 2006, 12:48 PM) [snapback]361626[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi i'd hazard a guess that this is purely a math question rather than php at all, but i can't see any way that $a=1 and $b=10 could ever create 15%, even by using 35 instead of 100 to work out the percentage?... maybe you could elaborate a bit more? Cheers Mark [/quote] I know, but I couldn't find anywhere else to ask, and I am trying to do it in PHP ;) Let me try to explain better. Depending on how close A is to B, I want to pick a number between 15-35. We could make it just 0-20 and add on 15 later. So if B is 20, it's easy: A=1, number = 0, so +15 = 15% when A = 10, number = 10, 25%. When A is 20, number=20 +15 = 35% Make sense? It's easy when B is 20, but if B is 7 and A is 4... How do I find the number on the scale? A..............B 0..............20
  20. Use cookies AND sessions to ensure the best security. You have cookie_username cookie_userid cookie_login (username+md5(pw)) session_login session_username session_userid Cookies can be edited, so you always want to make your code refer to the SESSION variables, NOT the cookies. You want to check on each page that the cookie login and username MATCH the session login and username. If the session doesn't exist, you get the info from the database using the cookie info and set the session. Otherwise, someone can change their cookie to whatever they want and if you don't verify it against the session, they'll get in.
  21. **SOLVED** Sorry if this isn't appropriate for here, but I can't figure out how to do this. I have two variables, a&b. I want to establish a percentage between 15-35 based on a&b. So if: $a = 0; $b = 10; $percent = 15% $a = 5; $b = 10; $percent = 25% $a = 10; $b = 10; $percent = 35% To summarize: the closer A gets to B, the higher the percentage is. So stuck on how to do this? Any help would be GREATLY appreciated, thank you SO much!
  22. Thank you. So it's because of the unique_id being in there too?
  23. Could someone help me fix this: [code]$get_items = "SELECT count(*) AS wood_count, unique_id FROM items WHERE owner = '$cookie_userid' AND location = 'inventory' AND item_id = 22"; if ($db_result = $db_conn->Execute($get_items)) {     if ($db_result->RecordCount()) {         while (!$db_result->EOF) {             $wood_ids[] = $db_result->fields['unique_id'];         }         $wood_count = $db_result->fields['wood_count'];     }     $db_result->Close(); } else     die('SQL Error #'.$db_conn->ErrorNo().': '.$db_conn->ErrorMsg()); [/code] It gives the error SQL Error #1140: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause Thanks.
  24. [!--quoteo(post=353022:date=Mar 8 2006, 03:44 PM:name=lessthanthree)--][div class=\'quotetop\']QUOTE(lessthanthree @ Mar 8 2006, 03:44 PM) [snapback]353022[/snapback][/div][div class=\'quotemain\'][!--quotec--] The only real advantage it has over intval is that if you are definitely expecting a number you can use something like if(!is_numeric($_GET["id"]) //print some kind of error. Which can quite often be useful. [/quote] Okay great, thanks :) I will remember that one.
  25. [!--quoteo(post=353011:date=Mar 8 2006, 03:36 PM:name=lessthanthree)--][div class=\'quotetop\']QUOTE(lessthanthree @ Mar 8 2006, 03:36 PM) [snapback]353011[/snapback][/div][div class=\'quotemain\'][!--quotec--] just to add. If you're expecting numbers as well as using intval you could use is_numeric() [/quote] Why would I do that? Doesn't that just find out if it is a number, wheras intval returns the numeric value? Can you explain the value of checking if it's a number? Thanks :)
×
×
  • 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.