Gayner Posted December 17, 2009 Share Posted December 17, 2009 Ok i got a session $_SESSION['rofl']; but i need a IF FUNCTION SO: if $_SESSION['rofl'] < 5seconds run mysql_query("DELETE FROM uonline WHERE time<$timech"); How will i do this ? thanks Quote Link to comment https://forums.phpfreaks.com/topic/185424-php-session-less-then-5-seconds-then-run/ Share on other sites More sharing options...
mikesta707 Posted December 17, 2009 Share Posted December 17, 2009 if ($_SESSION['rofl'] < 5) ?... Quote Link to comment https://forums.phpfreaks.com/topic/185424-php-session-less-then-5-seconds-then-run/#findComment-978872 Share on other sites More sharing options...
Gayner Posted December 17, 2009 Author Share Posted December 17, 2009 if ($_SESSION['rofl'] < 5) ?... 5 = Seconds? Quote Link to comment https://forums.phpfreaks.com/topic/185424-php-session-less-then-5-seconds-then-run/#findComment-978878 Share on other sites More sharing options...
mikesta707 Posted December 17, 2009 Share Posted December 17, 2009 if $_SESSION['rofl'] is in seconds than it will work... what does $_SESSION['rofl'] have in it Quote Link to comment https://forums.phpfreaks.com/topic/185424-php-session-less-then-5-seconds-then-run/#findComment-978884 Share on other sites More sharing options...
Gayner Posted December 17, 2009 Author Share Posted December 17, 2009 if $_SESSION['rofl'] is in seconds than it will work... what does $_SESSION['rofl'] have in it has nothing in it just a variable i can use so my query doesn't run each time a refresh happens only when a user logs out or after 5 seconds..? So if i use that, will the user have to refresh page for it to work or does php automatically run query after 5seconds ? Quote Link to comment https://forums.phpfreaks.com/topic/185424-php-session-less-then-5-seconds-then-run/#findComment-978886 Share on other sites More sharing options...
roopurt18 Posted December 17, 2009 Share Posted December 17, 2009 PHP code will only run when invoked by some mechanism. The three most common ways for PHP code to be invoked are: 1) The user makes a web request through your web server, i.e: apache 2) A user logs into a machine and runs a php script manually by calling: php.exe script_name.php 3) A scheduled task or cron job runs a php script by invoking a command: php.exe script_name.php So if i use that, will the user have to refresh page for it to work or does php automatically run query after 5seconds ? Based on what I've just told you, what do you think? a) user have to refresh page b) does php automatically run query after 5seconds Quote Link to comment https://forums.phpfreaks.com/topic/185424-php-session-less-then-5-seconds-then-run/#findComment-978897 Share on other sites More sharing options...
Gayner Posted December 17, 2009 Author Share Posted December 17, 2009 PHP code will only run when invoked by some mechanism. The three most common ways for PHP code to be invoked are: 1) The user makes a web request through your web server, i.e: apache 2) A user logs into a machine and runs a php script manually by calling: php.exe script_name.php 3) A scheduled task or cron job runs a php script by invoking a command: php.exe script_name.php So if i use that, will the user have to refresh page for it to work or does php automatically run query after 5seconds ? Based on what I've just told you, what do you think? a) user have to refresh page b) does php automatically run query after 5seconds I guess ur right, sorry about this... Just php so confusing for me..i try my hard tho and i learn alot from you guys.. just sometimes it get's really complicated.. i try my best i will learn it eventually, lol thanks... i found a online script online and just reverse engineering it now... thx Quote Link to comment https://forums.phpfreaks.com/topic/185424-php-session-less-then-5-seconds-then-run/#findComment-978902 Share on other sites More sharing options...
roopurt18 Posted December 17, 2009 Share Posted December 17, 2009 There's no need to apologize; the primary purpose of this site is for you to ask questions and learn from the responses (assuming the responses are worth learning from). Programming itself can be very confusing because your own internal thought process is very different from that of a computer. When your brain thinks "move my arm" your arm just moves. When you want to "move the computer's arm" it's not enough to just think it, you have to tell it how. And then you realize there's about 50 different ways you can try to tell it the "how." And just in case you understood it this way, my post was in no way meant to be condescending or make you feel stupid. You'll find that many responses in technical forums will be very terse or concise. It doesn't mean the person is being rude; more often it means they are being efficient in terms of word usage or are time limited because they are at work. Also, how much work a person will do on your behalf is sometimes an indication of what they think of you. My approach is to give you some information and then let you mull it over and come to a decision of your own. That's good practice for you because programming will present you with many opportunities to think about which solution is best or to come up with your own answer based on facts. If on the other hand someone just throws you the entire solution and explains nothing, it may mean one of two things: 1) They are time constrained and just need to be quick about it 2) They don't think you're worth explaining it to. Hope that helps some. Quote Link to comment https://forums.phpfreaks.com/topic/185424-php-session-less-then-5-seconds-then-run/#findComment-978911 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.