Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. Your card value function is incorrect. Just do a quick loop over your 1-52 range and you can see that: foreach (range(1,52) as $card){ echo cardValue($card).PHP_EOL; } /*----- an Ace 2 3 4 5 6 7 8 9 10 a Jack a Queen a King an Ace an Ace 3 4 5 6 7 8 9 10 11 a Jack a Queen a King an Ace an Ace 4 5 6 7 8 9 10 11 12 a Jack a Queen a King an Ace an Ace 5 6 7 8 9 10 11 12 0 -----*/ If you're not going to have the suit in there, you may as well just do a range of 0-12 (your range should be zero-based) and test that way. If you want to do the suit, then use range 0-51 and first extract the suit by doing $card/13, and then check the value of $card%13 to get the face value. function cardValue($card) { $suit = $card/13; $value = $card%13; if ($value == 0) $value = 'Ace'; else if ($value == 10) $value = 'Jack'; else if ($value == 11) $value = 'Queen'; else if ($value == 12) $value = 'King'; else $value++; $suitList=['Heart','Spade','Club','Diamond']; return $value.' of '.$suitList[$suit]; } foreach (range(0,51) as $card){ echo cardValue($card).PHP_EOL; }
  2. You'd have to install some kind of smtp server or sendmail-like program. What OS are you using?
  3. You need to convert your change$count variable to a number before you can add it. A quick way to do this is to just prefix it with a +. tbox$count.value = (+change$count)+1000;
  4. Supposedly it supports roman-numeral style month names, which 'I' would fall under, but the output doesn't seem to match with that action. If you run through 'a' - 'z', all except 'j' return a value of some kind however I cannot see any particular reason for the values they return. Such an input is unexpected and probably causes the parser to do something odd. If you really want to know what is happening, compile a debug version of PHP, set a breakpoint at the date parser function, and step through it
  5. Use something like TCPDF to generate a PDF file and output it for download.
  6. Simple sessions is fine. There is no need to do any encryption of the session data. For performance you could try using a session handler that uses memcache or similar rather than the default file-based handler. As far as securing sessions goes, read up on things like session hijacking / session fixation. If you will be on shared hosting, you'll also want to change the session save path to something under your directory rather than the system default.
  7. You'd need to build your own copy of PHP. Threads is not something that is standard with PHP, it is a PECL extension that you'd have to download and build. Look at the user notes on the installation page for some details. Depending on what exactly this server is supposed to do, you may not even need threads or processes to handle concurrent connections. Using non-blocking IO on the sockets will allow you to handle reading/writing multiple connections. You'd just have to make sure that processing for the sockets does not cause the script to block.
  8. Yes, for each user, within user_team you'd have 10 rows where u_id would be the same but p_id would change.
  9. Trying to build PHP yourself on windows is going to be a pain, you'll need to make sure you acquire and build any other dependency packages as well as PHP, such as zlib which is what your current error shows. What issues were you having trying to get the .dll to load? Try the builds available from http://www.apachelounge.com/viewtopic.php?p=25460 they contain the pspell dll.
  10. I've encountered a small hand full of servers in the past that due to some kind of incorrect configuration have problem routing to themselves, you could be seeing something like that. If you have SSH access to the server, login and try grabbing the file with wget or the curl commandline tool. Check to make sure the domain resolves properly. Check the firewall rules to see if maybe there is a rule blocking the traffic.
  11. Create a list of valid values and make sure what was submitted is in that list. eg: if (!in_array($_POST['confirmation_method'], ['order_management','telephone_keypad'])){ //invalid submission }
  12. You should have a third table to link up the users to their player choices. create table user_players ( userId int , playerId int , primary key(userId, playerId) ); You would have 10 rows for each user in the above table, one row per player choice.
  13. That is not at all correct. A SEGFAULT occurs when attempting to access an invalid memory location, such as trying to deference a null pointer. In theory, PHP should never SEGFAULT because the interpreter should not allow such conditions to happen. In practice, it'll happen sometimes due to bugs, unstable builds, poor extensions, etc.
  14. Your values in $gamenames do not line up with your row counter values. When you select 1,4, then $gamenames[0] and $gamenames[1] are set, not $gamenames[0] and $gamenames[3] which is what your code would require as it is right now. What you want to do is check whether $offerid exists anywhere within the $gamenames array, not if it exists specifically at $gamenames[$j]. You can do this by using the in_array function.
  15. The way you have your form setup right now, a user could select both radio options. It's not an either/or choice which is typically what radio buttons are for. Give it a try for yourself, click the first radio, then the second radio. Both will be selected. The way you are supposed to create radio groups is to give every radio button the same name, but a different value. And, in the odd case you'd actually want the two radios to function separately as they do, you still either need a value or need to change your code to work based on the name. Since the radio's have no value currently, $_POST['telephone_keypad'] would either be an empty string or maybe 'on', not sure how the browsers would treat that.
  16. It generates the name by concatenating '-' with $name. $name will be the name of the property which was trying to be accessed. For example: $obj=new MagicObject; echo $obj->SomeProperty; If there is no SomeProperty variable defined in class MagicObject (or it is inaccessible due to visibility rules), php will try to access it by calling __get('SomeProperty'), as if that code were re-written to: $obj=new MagicObject; echo $obj->__get('SomeProperty'); So in the __get code from your post, what happens is $protected_property_name gets set to the value '-'.$name; resulting in -SomeProperty. Then it checks if that variable exists on the object and if so, returns it.
  17. Hence why my suggestion was that you change the value of scrollTop AFTER you reset the overflow property.
  18. $one = 3; $two = 5; $three = 7; //equation 5 $three = $two + $two; //5 + 5 = 10, store 10 in $three //equation 3 $three = $three + $two; //10 + 5 = 15, store 15 in $three
  19. Or, just tack on a GET variable. header('Location: form.php?redir=1'); Then check for $_GET['redir'] in form.php
  20. Try reading the scroll height into a variable, then reset the overflow, then change the scroll top to the previously read height.
  21. Each element in the report array is another array, with index [0] being the address and [1] being the object with additional details. So you need to access $rep[1]['immatureBalance'].
  22. You just create a looping construct in your template. How you do this depends on how you are doing your templates. If you do like smarty for instance and use {tag} placeholders then you'd create a tag such as {foreach}. As you parse the template you extract the text between {foreach} and {/foreach} and use that in a loop. This is just off the top of my head and untested, so there may be bugs, but as a basic example: $tplVars['var']=array(1,2,3,4); $template = 'Before the loop. {foreach $var}In the loop!{/foreach} After the loop!'; for ($pos=0; ($pos=strpos($template,'{foreach ',$pos)) !== false; $pos++){ $end = strpos($template,$pos+1); if ($end === false) die('Error'); $end += 10; //length of '{/foreach}' //Extract the code for the loop from the template (including tags) $code = substr($template, $pos, $end-$pos); //Extract the variable name $varToLoop = substr($code, 0, strpos($code, '}')); $varToLoop = substr($varToLoop, strrpos($varToLoop, ' ')); //Strip the tags from the code $code = substr($code, strpos($code, '}')+1); $code = substr($code, 0, strrpos($code, '{')); if (!isset($tplVars[$varToLoop])) die('Error'); $output = ''; foreach ($tplVars[$varToLoop] as $var){ $output .= $code; } //Replace the tags in the original template w/ the generated output. $template = substr_replace($template, $output, $pos, $end-$pos); } var_dump($template); On the other hand, you could just let PHP handle the templating for you in which case you don't need to do anything other than write a normal loop. This is what I do: Before the loop! <?php foreach ($var as $v): ?> In the loop! <?php endforeach; ?> After the loop! When you want to use the template, it's just a simple matter of include()ing it.
  23. div tags do not have an href attribute. Perhaps you mean <iframe> ? Using an iframe would show the site without it's URL being visible in the URL bar, but it would still be visible in the source of the page, so it's not really hidden.
×
×
  • 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.