Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. would also like to point out that true will only equate to 1 and false will only equate to 0 or '' if they are loosely compared. If you strictly compare them then they do not equate. For example: if (true == 1) echo "true == 1 "; // this will echo if (true === 1) echo "true === 1 "; // this will not echo if (false == 0) echo "false == 0 "; // this will echo if (false === 0) echo "false === 0 "; // this will not echo if (false == '') echo "false == '' "; // this will echo if (false === '') echo "false === '' "; // this will not echo
  2. well how do you know what you are(n't) getting unless you're looking at it somehow?
  3. what are you doing to compare the returned value
  4. come on man, make an effort. First set $device to false. then the switch stuff. Then wrap a condition around the button to check if $device is not false.
  5. yes, you can have a form field to select an existing image (file) on the phone and upload it.
  6. simple script showing the basics of IMAP with yahoo (use your own username/password): /* connect to yahoo */ $hostname = '{imap.mail.yahoo.com:993/imap/ssl}INBOX'; $username = '[email protected]'; $password = 'password'; /* try to connect */ $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to yahoo: ' . imap_last_error()); /* grab emails */ $emails = imap_search($inbox,'ALL'); /* if emails are returned, cycle through each... */ if($emails) { /* put the newest emails on top */ rsort($emails); /* gonna just output some basic info in table format */ echo "<table>"; echo "<tr align='left'>"; echo "<th>FROM</th>"; echo "<th>DATE</th>"; echo "<th>SUBJECT</th>"; echo "</tr>"; /* for every email... */ foreach($emails as $email_number) { /* get information specific to this email */ $overview = imap_fetch_overview($inbox,$email_number,0); /* echo basic info about it */ echo "<tr>"; echo "<td>".$overview[0]->from."</td>"; echo "<td>".$overview[0]->date."</td>"; echo "<td>".$overview[0]->subject."</td>"; echo "</tr>"; } echo "</table>"; } /* close the connection */ imap_close($inbox);
  7. any particular reason why you are trying to use cURL to access your yahoo mail, instead of using IMAP or POP3 ?
  8. $managerID = preg_replace('#[^0-9]#i', '', $_SESSION["id"]); This strips anything that is not a number out of the $_SESSION["id"] variable and assigns the results to $managerID. Note: there is an i modifier being used here, which makes the match case-insensitive. This is not necessary for this pattern, since only numbers are expressed. $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["manager"]); This strips anything that is not a letter or number out of the $_SESSION["manager"] variable and assigns the results to $manager. Note: there is an i modifier being used here, which makes the match case-insensitive. This is not necessary for this pattern since the pattern already explicitly matches for upper and lowercase letter ranges. This is the pattern delimiter, what specifies the beginning and end of the pattern. You can use pretty much any non-alphanumeric character. A lot of people use / instead because in some languages, that's the only thing available. But using # or ~ is also popular because many times people use regex to parse html/xml content and since / comes up a lot in that content, you have to escape it if you're matching for it within the pattern itself so that php doesn't doesn't get confused by where your pattern actually ends.
  9. $_SERVER['HTTP_ACCEPT'] just specifies what type of file types or media the client can/will accept as a response. This isn't really useful for mobile device detection specifically, though indirectly I suppose you could use it for some feature detection, which I guess is indirectly relevant to displaying stuff.. Anyways, normally you would parse $_SERVER['HTTP_USER_AGENT'] to detect the mobile device.
  10. <?php $ua=$_SERVER['HTTP_USER_AGENT']; switch(true) { case stripos($ua,'android') : $device = 'android'; break; case stripos($ua,'ipad') : $device = 'ipad'; break; case stripos($ua,'iphone') : $device = 'iphone'; break; } ?> <ul class="pageitem"><li class="button android"><input name="Submit" value="App Downloads" onclick="window.location='apps.php?id=<?php echo $device; ?>' " type="submit" /></li></ul>
  11. Okay so for your percents per level, basically you will want to have a map/table for each of your levels. One way to do this is to just hardcode an array with the percents you want. For example: $percents = array(1=>80,20=2);I just showed your first and last level as an example; you'd add levels 2-19 with your own values. The benefit if doing it this way is that you have more control over balancing your game. Alternatively, if you just want to do something simple like make it an even(ish) spread, you could automate this with a formula: $percents = array(); $minLevel=1; $maxLevel=20; $minPercent=2; $maxPercent=80; for ($p=$minLevel;$p<=$maxLevel;$p++) { $percentInc = ($maxPercent-$minPercent)/($maxLevel-1); $percent = $maxPercent-(($p-1)*$percentInc); $percents[$p] = $percent; } This will give you an array of percents like this: Array ( [1] => 80 [2] => 75.8947368421 [3] => 71.7894736842 [4] => 67.6842105263 [5] => 63.5789473684 [6] => 59.4736842105 [7] => 55.3684210526 [8] => 51.2631578947 [9] => 47.1578947368 [10] => 43.0526315789 [11] => 38.9473684211 [12] => 34.8421052632 [13] => 30.7368421053 [14] => 26.6315789474 [15] => 22.5263157895 [16] => 18.4210526316 [17] => 14.3157894737 [18] => 10.2105263158 [19] => 6.10526315789 [20] => 2 ) IMO you should prolly throw some rounding into the mix but that's a judgement call you'll have to make.
  12. $string = preg_replace('~\b([^.]+)\.([^@]+)@domain\.com~','$1 $2',$string);
  13. so is the problem, that GA numbers don't match up hits shown in your server log? How big of a difference is it?
  14. why would you even mention for him to go to the site and do it in the console? The whole point of coding is to automate something so that you don't have to manually do it yourself.
  15. you cannot use javascript to get contents from a page hosted on another domain, unless the target domain is specifically setup to allow cross domain scripting.
  16. show what you have tried to do
  17. and i ignored it. This is a free, public help site. If you want free help, it must be public. If you want me to respond to your PM and work with you specifically, that will cost you money.
  18. well what did you actually change? explain what you are attempting to do with that part of the code.
  19. string example: you have a value and the quotes mark the beginning and end of the value. $myString = "my value";if you want to have quotes in your string: $myString = "she said "hi!" to me"; This won't work because now php thinks the value ended at "she said ". So you can escape the inner quotes: $myString = "she said \"hi!\" to me"; or you can use single quotes: $myString = "she said 'hi!' to me"; or you can use heredoc syntax to mark the beginning and end of the string and not worry about escaping quotes: $myString = <<<EOS she said "hi!" to me another string with 'single' quotes EOS; this makes <<<EOS the beginning delimiter and EOS; the ending delimiter so you can use either or both quotes in your string without having to worry about escaping them.
  20. well i don't know what the intentions are, but basically up in line 49 you use $r to loop through database results, and the way the loop works is either $r gets some results (a numeric array of columns returnedfor the current row of results) or else (boolean) false. The loop doesn't end until $r gets a value of false. Then, down on line 59 you attempt to assign $r[0] to $maxnum[] well by that time, $r is false (a scalar, boolean value), not an array, so there is no $r[0] index.
  21. so what are you saying, you don't know how to change all the double quotes to single quotes?
  22. preg_match('~[0-9]+\s*-\s*[0-9]+\s*-\s*[0-9]+\s*-\s*[0-9]+~',$content,$match);
  23. you already looped through the results once, so first you need to reset the internal pointer: mysqli_data_seek($result,0); Then you need to loop through it same way as before
  24. And I want a pony. I feel like we've had this conversation before.
  25. I want a pony.
×
×
  • 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.