Jump to content

Zane

Administrators
  • Posts

    4,362
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zane

  1. $return = $num; if($count >= 1) $return = Randomize::createRN(); else return $return; The main thing wrong with your code is your use of $repeat. It is never declared beforehand AND you never use it when you do declare it.
  2. This is called a ternary statement. It's nothing more than if/else shorthand; whereas there is only one statement per clause. if($_GET['client'] != "") $client = $_GET['client']; else $client = "default"; include("somewebjpage?x=" . $client); is the same as $client = ($_GET["client"] != "") ? $_GET["client"] : "default"; include ("somewebjpage?x=" . $client);
  3. yeah, the date() function date(strtotime("03-02-2011"), "d-M-Y");
  4. are you calling it multiple times?
  5. INNER JOIN communications ON records.IDNumber should be INNER JOIN communications ON communications.CommID
  6. Perhaps a ternary statement as well then. $_SESSION['x1'] = isset($_SESSION['x1']) ? $_SESSION['x1'] : random_number (); $_SESSION['x2'] = isset($_SESSION['x2']) ? $_SESSION['x2'] : random_number (); $_SESSION['op'] = isset($_SESSION['x3']) ? $_SESSION['x3'] : random_op ();
  7. The last version I made should still be in the Staff Area somewhere as an attachment, if you need it.
  8. mysql_pconnect() maybe?
  9. So am I right in understanding that you are POSTing a users privileges to every page/script they go to? In other words, you're storing data that you need in multiple place, over and over again. Like they way verizon asks you to put your phone number before getting to a CSR, when you know for a fact of experience that they don't even use the number you entered. You should store your permissions in a session if you need them in so many functions/scripts. As for the array problem, I can't understand your elaboration.. why does it work "to a point"?
  10. Here ya go. $array1 = array(500,503,9909,887,454) $array2 = array(100,223,200,109,500,503,9909, 787, 887,454); $array3 = array(223,200,109,500,503,9909); foreach($array1 as $v) { if(in_array($v, $array2)) { $findIt = array_search($v, $array2); unset($array2[$findIt]); } if(in_array($v, $array3)) { $findIt = array_search($v, $array3); unset($array3[$findIt]); } else $array3[] = $v; }
  11. If you're sending an array through POST then you have to access it like an array For instance, you have a list of checkboxes in an array called checks[]. On your POSTED page you will have a variable called $_POST['checks'] You can access the elements of that array, just like you would any other array $_POST['checks'][0] == first checked value $_POST['checks'][1] == second checked value $_POST['checks'][2] == third checked value $_POST['checks'][3] == fourth checked value $_POST['checks'][4] == fifth checked value
  12. obviously $value is an array what happens when you change all $value to $value[0] in the areas outlined for elements.
  13. There is an algorithm called levenshtein which does exactly this... somewhat. What it does is give you "the minimal number of characters you have to replace, insert or delete to transform str1 into str2". Once you have this number, you can then compare it with the actual length of the string. So for instance, the levenshtein between "I eat food" and "I ate food" would be 3 (I believe). You would then take that number and divide it by the length of "I eat food".. AKA str1. 3/10 = 30-33% different. At least that's how I'd do it, I'm sure there are better ways.
  14. When you set your file pointer $fp = fopen('text.txt','w'); That w at the end means.. Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it. You want a... Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it. This can all be found in the manual under fopen
  15. The layout preview you supplied looks as if you're using Adblock...or something similar
  16. There's always the ternary statement route document.getElementById(element).style.display = document.getElementById(element).style.display == 'block' ? "none" : "block";
  17. There's really no way around it without implementing a registration system; even then, there would be some complex queries involved. Though still, that's the best route. Reason being, IPs can be changed and Cookies can be deleted... .. and well, Sessions speak for themselves.
  18. Ah, wasn't thinking in terms of PHP, d'oh along with gizmola's solution you can use this ordinal function to get your 1st 2nd 3rd,etc functionality Straight from PHP.net manual http://www.php.net/manual/ro/function.is-numeric.php#99876 function ordinal($i='') { // a temporary value we can change, and keep the original value. $o=$i; // suffixes = 0th, 1st, 2nd, third == zeroth, first, second, third $s=array('th','st','nd','rd'); // if input just so happens to be a string, we check to make sure it // still holds a numeric value and only acquire the last 2 numbers. // if it's not a string, nor an integer, we freak out and say no. if(!is_int($o)) if(ctype_digit($o)) $o=(int)substr($o,-2,2); else return(false); // basically, if $o is between 11 and 19, we use 'th' // otherwise we use the last digit and if it's over // 4 then we use 0 (for the $s array index). return($i.$s[($o%100>10&&$o%100}
  19. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=312470.0
  20. Ok, I see now. I'm not too familiar with doing ranks like that, but I came across a tutorial that might help http://www.fromdual.ch/ranking-mysql-results
  21. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=312460.0
  22. What does your table structure look like.. and how are you calculating the percentages. Also, right off the bat, I can tell you the solution to this is that you need your percentage decimal to go to the farthest decimal place possible, in order to get an accurate ranking. Example... 2nd place == 99.86535758 3rd place == 99.86531115
  23. you might want to utf8_decode BEFORE serializing foreach($array as $value) utf8_decode($value); $s_array = serialize($array); echo "", print_r($s_array), "";
  24. Patience is a virtue.
×
×
  • 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.