heckenschutze
-
Posts
257 -
Joined
-
Last visited
Never
Posts posted by heckenschutze
-
-
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.
-
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.
-
Or phishy, get it phishy...
-
I don't see where you send the header of the content type... that it's jpeg
header("Content-type: image/jpeg");
Or something
-
-
-
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().
-
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.
-
$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.
-
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.
-
$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...
-
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.
-
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.
-
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();
-
Remember that a UNIX timestamp only has precision until 2038, http://en.wikipedia.org/wiki/Year_2038_problem
The number of the year, may be a two or four digit value, with values between 0-69 mapping to 2000-2069 and 70-100 to 1970-2000. On systems where time_t is a 32bit signed integer, as most common today, the valid range for year is somewhere between 1901 and 2038. However, before PHP 5.1.0 this range was limited from 1970 to 2038 on some systems (e.g. Windows).
But you're not using a timestamp to store the year, so most likely your clock is wrong.
-
Have you checked your php.ini to ensure that you're loading the mysql module?
-
> You must use require() instead of include() as the former is faster in terms of execution than the latter.
No it isn't.
-
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.
-
-
That's not PHP related
But anywho, Profile -> Forum Profile Information, scroll down to Signature.
-
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]
-
Use spaces instead of tabs, seriously.
`wp_posts`.`post_date` should be `wp_posts.post_date` or something.
-
Learn how to indent, it's very hard to read.
-
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.
Searching a Tab Deliminated Text File (I dont even know where to start)
in PHP Coding Help
Posted
No, but there are regular expressions, take your pick between POSIX or PCRE regex