Jump to content

heckenschutze

Members
  • Posts

    257
  • Joined

  • Last visited

    Never

Everything posted by heckenschutze

  1. No, but there are regular expressions, take your pick between POSIX or PCRE regex
  2. If you want to search for the id: <?php $h = NULL; $cols = array(); $line = ""; if(($h = @fopen('file.txt', 'rb')) === FALSE) die('Failed to open some file'); while(($line = @fgets($h)) !== FALSE) { $cols = explode('\t', $h); /* $cols[0] is the fileid */ /* $cols[1] is the filename */ } fclose($h); ?> Search or do whatever.
  3. Don't do that, what if the user used a proxy server? Or several proxy servers? Some ISPs even use proxy servers, so your user would be pretty pissed off if you told them their account had been 'hacked' when they try to log in. Just chuck an extra field in your user table, 'lastAction' or something. Which stores a timestamp of their last action, if someone else tries to login in a time say greater than 'lastAction' + timeout then let them (and destroy the original session), else don't.
  4. I don't see where you send the header of the content type... that it's jpeg header("Content-type: image/jpeg"); Or something
  5. Nothing really to fix it, $hours = diffHours(strtotime($row3['datetillcompletion']), time()); Does that work? you just need to pass 2 timestamps to diffHours. strtotime() converts a string to a timestamp. You should consider changing your database so dates/times are stored as unix timestamps, you can get the current time with time().
  6. diffHours() will tell you the difference between 2 unix timestamps, in hours. A unix timestamp is how many seconds have past since the UNIX EPOCH (1970), once you realize that it's pretty easy. You should be storing the timestamp in the database, not a string.
  7. $hours = diffHours($row['datetillcompletion'], time()); Returns the amount of hours between the 'datetillcompletion' and the current time. Note: It really helps if you understand unix timestamps, no need to convert it to a string, then back to a timestamp.
  8. Just for example, so the times were different Can chuck it in a function for a one liner, function diffHours($a, $b) { return (abs($a - $b) / pow(60, 2)); } abs() because we only care about the difference in scalar terms.
  9. $time1 = time(); $time2 = time() + 328523; /* some random number */ $dSecs = abs($time2 - $time1); $dHours = $dSecs / pow(60, 2); Something like that, there is probably a PHP function to do this...
  10. I've written something exactly like that in C before, it's very easy - just it's harder in PHP, being scripted etc. But try and structure it well, use an array rather than a string.
  11. I'd suggest starting again for the date/time, you seem to be making it hard on yourself. A unix timestamp the the no. of seconds after 1970. $ourTime = time(); $gameTime = array( 'year' => date('Y', $ourTime) + 2404, 'month' => date('m', $ourTime), 'day' => date('d', $ourTime)); echo 'Game year is ' . $gameTime['year']; Set it out something like that, you can change $ourTime to the start time, and just factor in how far in days, seconds, years or whatever the game time is ahead. No need to keep going back and forth.
  12. Why make it so hard on yourself? $realTime_current = mktime(date("H"), date("i"), date("s"), date("n"), date("j"), date("Y")); Is the same as $realTime_current = time();
  13. Remember that a UNIX timestamp only has precision until 2038, http://en.wikipedia.org/wiki/Year_2038_problem But you're not using a timestamp to store the year, so most likely your clock is wrong.
  14. Have you checked your php.ini to ensure that you're loading the mysql module?
  15. > You must use require() instead of include() as the former is faster in terms of execution than the latter. No it isn't.
  16. Your script will stop if config.php can't be included if you use require(), for any reason. Ie it doesn't exist or PHP doesn't have privs to read the file. include() will issue a warning if config.php cannot be included, but will continue running the script. Use require() for vital files, and include() for other non-vital things.
  17. sf.net: http://sourceforge.net/projects/restaur-reserve/ Python & PostgreSQL, but it's close
  18. That's not PHP related But anywho, Profile -> Forum Profile Information, scroll down to Signature.
  19. Use strpos, or a simpler regex, there won't always be a space after 'bout ie: "that's all it's 'about". You'll want to match, [space][single apostrophe][a-z]
  20. Use spaces instead of tabs, seriously. `wp_posts`.`post_date` should be `wp_posts.post_date` or something.
  21. Learn how to indent, it's very hard to read.
  22. d.shankar don't be such a loser. You obviously didn't read my post, I said if you charge for your script/service you could have a problem. I don't work here for money, in fact I don't even work with PHP.
×
×
  • 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.