Jump to content

Gibbs

Members
  • Posts

    63
  • Joined

  • Last visited

    Never

About Gibbs

  • Birthday 05/11/1987

Contact Methods

  • Website URL
    http://www.dangibbs.co.uk

Profile Information

  • Gender
    Male
  • Location
    Devon

Gibbs's Achievements

Member

Member (2/5)

0

Reputation

  1. I have done this before but not in PHP. I don't think it would be possible in PHP unless you are allowed to use some dangerous functions such as exec. That would still rely on external software though.
  2. The idea is that it keeps generating passwords (or in this case tokens) until it finds a unique one. Excellent. That makes a lot more sense! Thanks.
  3. You have two main options off the top of my head. You can base64 encode the image an put it directly into the HTML document. This is perfectly acceptable for small images. <?php // Not tested $image = base64_encode($row['image']); $output = 'data:image/jpg;base64,' . $image; ?> <img src="<?php echo $output ?>" /> Or you will have to create a separate script and set the content type in a header. Then you would link to the script in the src attribute. <?php // Not tested $image = $row['image']; header("Content-type: image/jpg"); echo $image; Or you could write the image to the filesystem, which I doubt you want to do.
  4. Apart from the fact this can cause an infinite loop is it OK to use? $user->reset_token = $user->generate_password(32); // Make sure the token is unique while(TRUE) { $count = ORM::factory('manager')->where('reset_token', '=', $user->reset_token)->count_all(); if($count < 1) break; $user->reset_token = $user->generate_password(32); } Or would you approach the logic for this differently? Thoughts appreciated. Cheers
  5. I'm trying to find the two largest values in an array. The max function is great but I'm also looking for the second largest number... I can't use any sorting functions as the array name must stay the same. The sort functions I've tried, for example, will rename $array["TEST1"] to $array[0]. Any help appreciated. Thanks.
  6. Thanks for the help. Managed to come up with this. Still long but cuts the code down. <?php for ($x = 0; $x < 8; $x++) { $sectSel = "LLL"; switch($x) { case 0: $partSearch = "LLL"; break; case 1: $partSearch = "FFF"; break; case 2: $partSearch = "GGG"; break; case 3: $partSearch = "BBB"; break; case 4: $partSearch = "MMM"; break; case 5: $partSearch = "CCC"; break; case 6: $partSearch = "EEE"; break; case 7: $partSearch = "VVV"; break; } if ($arrayData[sect][$sectSel][0][$partSearch] == "E") { $eString[$sectSel] = $eString[$sectSel]." ".$partSearch; } } echo $eString[$sectSel]; ?>
  7. Array ( [sect] => Array ( [LLL] => Array ( [0] => Array ( [CCC] => A [FFF] => A [VVV] => A [GGG] => A [EEE] => A [MMM] => E [bBB] => E ) ) [FFF] => Array ( [0] => Array ( [LLL] => A [GGG] => A [bBB] => N [MMM] => E [CCC] => N [EEE] => A [VVV] => A) ) That's an example of the array. I'm guessing its four-dimension? Using the first part for LLL I need to echo the value of each (if it equals A) arrays value (like CCC) as well as the array name CCC. The output would need be something like: A CCC A FFF A VVV A GGG A EEE
  8. I haven't got any experience with most array functions so I'm finding it difficult to be creative. Anyway... I have an array that has multiple arrays inside it. I'm trying to find the value of each array. The problem is that I also need to know the name of the array that is in use. Heres an example of what I'm doing: if ($arrayData[sect][TEX][0][AAA] == "A") { $ret_a = $ret_a."AAA "; } if ($arrayData[sect][TEX][0][GGG] == "A") { $ret_a = $ret_a."GGG "; } if ($arrayData[sect][TEX][0][bBB] == "A") { $ret_a = $ret_a."BBB "; } if ($arrayData[sect][TEX][0][MMM] == "A") { $ret_a = $ret_a."MMM "; } if ($arrayData[sect][TEX][0][CCC] == "A") { $ret_a = $ret_a."CCC "; } if ($arrayData[sect][TEX][0][EEE] == "A") { $ret_a = $ret_a."EEE "; } if ($arrayData[sect][TEX][0][VVV] == "A") { $ret_a = $ret_a."VVV "; } That's a lot of code especially as I have to find out B, C and search another 7 of these. I'm probably not making any sense whatsoever but it's difficult to explain. Basically I need to find out all the arrays inside $arrayData[sect][TEX][0], find it's value AND return the name of that array. This is being done from a live feed so I can't change the XML file unfortunately. I can do this but 147 lines is a waste of time... Any help appreciated!
  9. You can check if the file exists by using the file_exists function prior to uploading. Never done this so I can't be 100% sure. With the move_uploaded_file function you can specify the path. For example: move_uploaded_file($_FILES['upfile']['name'],<where you want it/filename>)
  10. I know it can be made shorter but that doesn't help. The game time is 4 times faster then ours so 1 day is 4 days in the game. To calculate that you need to calculate the amount of time lapsed from X date to current date * 4. I'll have a play around with it though. Cheers.
  11. Don't get me wrong (my PHP is appalling on some functions) but I think I need a specific format for this to work?
  12. To calculate the year I've made an integer without using the mktime function. I don't think that's the problem as I have "2405" being printed locally and remotely on a PHP 5 server. I've checked the date and time config on the server and it's correct (except 4 hours behind). I've altered the script to suit that as the PHP 5 server was also 4 hours behind. $fom_year = 2404 + (2007 - 2007); doesn't equal 2367. Confused...
  13. Nevermind. Can't keep up with gurus...
  14. Your trying to loop a query to output multiple results? Why not use: $q = mysql_query(your query); while ($r = mysql_fetch_array($q)) { // Do this }
×
×
  • 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.