PC Nerd Posted April 5, 2007 Share Posted April 5, 2007 um, i get that its expecting an ";" on the while loop line, do{ $Login = mysqli_fetch_array($Login_Query); $Latest_time = $Login['Logged_In']; } while($Login = mysqli_fetch_array($Login_Query)) { if($Latest_time < $Login['Logged_In']) { $Login_ID = $Login['Login_ID']; } } there is it meant to go??? ive highlited the line where the ";" is expected. thanks in advance, PC Nerd Quote Link to comment Share on other sites More sharing options...
almightyegg Posted April 5, 2007 Share Posted April 5, 2007 {color] I have no idea what that's about but I'm sure that's the problem Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 5, 2007 Author Share Posted April 5, 2007 there you go, thankx whats wrong do you think? Quote Link to comment Share on other sites More sharing options...
almightyegg Posted April 5, 2007 Share Posted April 5, 2007 color] looks like the second half of a variable, it won't work on it's own and hasn't been given an instruction therefore will cause errors... remove that and it should work Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 5, 2007 Author Share Posted April 5, 2007 i dont understand????? Quote Link to comment Share on other sites More sharing options...
gluck Posted April 5, 2007 Share Posted April 5, 2007 {color] <- right here Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 5, 2007 Author Share Posted April 5, 2007 um ok ive changed the post and i cant see that anywhere. ive fixed that and now only the error line is highlited blue. if you cant see it properly, then let me know, and ill repost the code..... Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 5, 2007 Share Posted April 5, 2007 I think PHP is getting very confused with how you wrote the loop. Try this instead: <?php while($Login = mysqli_fetch_array($Login_Query)) { $Latest_time = $Login['Logged_In']; if($Latest_time < $Login['Logged_In']) $Login_ID = $Login['Login_ID']; }?> But looking at the above, the logic doesn't make any sense. What are you trying to accomplish? Ken Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 5, 2007 Author Share Posted April 5, 2007 im looping through all your logins, to determine what the most recent login time is. then storing it Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 5, 2007 Share Posted April 5, 2007 What format is the login date/time stored in? If it's not a UNIX time stamp, then a simple comparison won't work. Try this code (it assumes the login date/time is stored as "YYYY-MM-DD HH:MM:00") <?php $current_time = time(); // get the current time as a UNIX Timestamp $most_recent = 0; // initialize to earliest possible login time while($Login = mysqli_fetch_array($Login_Query)) { $Latest_time = strtotime($Login['Logged_In']); if(($current_time - $Latest_time) < ($current_time - $most_recent)) { $most_recent = $Latest_time; $Login_ID = $Login['Login_ID']; } }?> Ken Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 5, 2007 Author Share Posted April 5, 2007 that wont work. i am storing all login details in a database first it write a new"login record, with a unique login id. but what i want to do is to find the most recent login ( ie the one that just happened ) so thatg i can store the login id in a cookie, so that i can easily pass the database throughout the members are, if theres a better way of doing this, then please tell me. i originally wanted to just use cookies, but i want to store how much time a use is logged in for, so this is the best the database field is a timestampe, and is default to the the surrent timestamp, ie, NOW, but when we try to get that recond out again acording to timestamp, the timestamp will be different becausae of the number of milli seconds......... if theres a better way, or my plan is completely screwed up, please let me know thanks for your help, PC Nerd Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 5, 2007 Author Share Posted April 5, 2007 does anyone else have any suggestions????? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 6, 2007 Author Share Posted April 6, 2007 anymore ideas??? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 6, 2007 Author Share Posted April 6, 2007 anyting??? thankx Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 6, 2007 Author Share Posted April 6, 2007 does anyone have any idea to what to look for, or how to organise this?????? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 7, 2007 Author Share Posted April 7, 2007 please???? Quote Link to comment Share on other sites More sharing options...
per1os Posted April 7, 2007 Share Posted April 7, 2007 <?php $Login = mysqli_fetch_array($Login_Query); do{ $Latest_time = $Login['Logged_In']; }while($Login = mysqli_fetch_array($Login_Query)); ?> That is the correct syntax for the do,while. Do whiles are for when you always want certain code to execute. But you have a flaw for an infinite loop by putting the $Login inside the do while, because it never loops if that makes any sense. I would suggest you look into the type of operations you are trying to do before just doing them. IE read up on Do Whiles and the correct syntax. Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 7, 2007 Author Share Posted April 7, 2007 thankx do you have any help with the login timestamp or is that another thread? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 7, 2007 Author Share Posted April 7, 2007 ill make a new thread abut the timestamp storage, thankx anyway Quote Link to comment 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.