PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
hi ..
i am working on chat system ..there are two types of user one are register and other are guest and i have to add guest user..in to database as temporary so they can chat with each other the problem i am facing is with there names i want name like this (Guest1,Guest2,Guest3,Guest4,...so on..)..i am trying but it is not working on live server .. i have tested it on my local server using xampp server.. it worked but not on live server...
Advice is to use auto_increment ID on database table, and upon inserting new guest into db, check for biggest ID in table (do some google magic with MySQL 'MAX' keyword), bind 'Guest' word with MAX_ID+1 value, and that's it.
waqas87 wrote:and one more thing how i can delete Guest users who are not online..
Put 'last_activity' column in regarding database table which will be updated on every user/guest action, and on users 'login' check if there are users/guests with last activity that is by your opinion enoguh to declare someone 'offline'. Do time_now - last_activity difference to check it.
The problem is that $_SESSION variables are different for each user. You can not just check if a session variable is set and increment it because each user has their own session variables. You need to use a database.
$delete = "DELETE FROM tbl_GuestUser WHERE GuestLogtime < NOW() - INTERVAL 300 SECOND";
$record = mysql_query($delete) or die("DELETE SQL query failed");
to delete guest from database but this delete every user..i have one field as GuestLogtime which store Guest login time ....and the sub from current time ..