Jump to content

delete a colum from a row


mc_keny

Recommended Posts

HEY guys.. i set up a session thing on my login page when the user login i have $time = time();$xtime = ($time +60*60);in the users table i have a colum call extime so each time they log in it update if there not active it wont update next i have a function that i want to delete expire time mysql_query("DELETE FROM mc_users WHERE extime<'".time()."'"); which mean if time is greater than expire time delete the expire time but instead it delete the user :)when every there session run out...i just want it to delete the expire time any help please

Link to comment
Share on other sites

you create a new table called sessions, which has the columns session_id, session_user, session_start, session_extimeThen you just call that delete command from the session table instead of the user table.If you don't feel like making another table, then you just use 'UPDATE mc_users SET extime = NULL where extime < '.time()

Link to comment
Share on other sites

THANKS ALOT MATE SO PHP AINT ABLE TO DELETE FROM A COLUM INSTEAD OF DELETING THE WHOLE ROW? another thing i have at the top of each page if the user didn't sign in are there session expire it says your session has expire or you didn't sign in it works well but a lil prob on tha index page am using the switch statement eg

switch ($ac){case signin:break;case signup:break;case profile:break;case cpanel:break;default://main page//this is where they select the sign in and sign up link the prob is when then come to this page they get the message your session has expire or you didn't sign in how do i make it so they can only view the default page without getting that message

i hope you guys understand what i mean

Link to comment
Share on other sites

THANKS ALOT MATE SO PHP AINT ABLE TO DELETE FROM A COLUM INSTEAD OF DELETING THE WHOLE ROW?
You could just set the column value to NULL
UPDATE mc_users SET extime = NULL WHERE extime < NOW()

Link to comment
Share on other sites

THANKS ALOT MATE SO PHP AINT ABLE TO DELETE FROM A COLUM INSTEAD OF DELETING THE WHOLE ROW?
PHP can only delete rows. You aren't deleting the column value, that would require you to alter the table. You are just Updating the columns. You delete rows, you update columns. As for your other problem, I'm not understanding the issue that you're having, could you attempt to explain it a bit more.
Link to comment
Share on other sites

THANKS ALOT MATE SO PHP AINT ABLE TO DELETE FROM A COLUM INSTEAD OF DELETING THE WHOLE ROW?
Just to point out, PHP doesn't have anything to do with it. The SQL database is doing the data manipulation, all PHP does is send SQL code to the database to get executed.
the prob is when then come to this page they get the message your session has expire or you didn't sign in how do i make it so they can only view the default page without getting that message
Where does the message come from?
Link to comment
Share on other sites

ok i have this function

function signin($tid){mysql_query("UPDATE mc_users SET extime='NULL', tid='NULL' WHERE extime<'".date("i")."'");$check = mysql_fetch_array(mysql_query("SELECT * FROM mc_users WHERE tid='".$tid."'"));$t = date("i");if($check[0]>0){return true;}else{return false;}} i place this on every pageif(!signin($tid)){echo cardhead(ERROR);echo "your session has expire..or you didn't sign in $s";echo signin_form();echo cardfoot();}//TID IS THE TIME ID so each time they sign in they get a new time id$tid=$nick.time();echo "<a href=\"index.php?main&tid=$tid\">login</a>";//so when every the time expire there time id get delete any   page there on they get the error message saying your time has expire or you didn't login, what i want now is if the user get my url http://v3.site.com i dont want them to see that message case sign:break;case main:break;default:this is the page i want them to see but because i have the function at the top they get the error message

Link to comment
Share on other sites

thanks mate but as i said i have if(!signin){your not logged in or your session has expire}on every page on the top so if a user even type http://site.com/index.php?ac=main they will see that message but if they go to http://site.comi want them to see the default: switch statement so they will be able to select sign in from there -much clearer-

Link to comment
Share on other sites

... its the same file... which honestly, seems like you could do something better with your script here, personal opinion.You have to check to see if the $_GET value ['ac'] is defined. If it is, then print out the error. If not, just display the page.

Link to comment
Share on other sites

lol your saying am lazy ? lol anyways thanks the if(isset($ac)) works the only prob is because i have the sign in in the same file they get that message am just gonna make a file for the sign in but if you guys suggest anyways i could make the sign in work in the same file without getting the error msg let me know -cheers-

Link to comment
Share on other sites

You didn't understand what I said. When the user logs in use the session to indicate that they are logged in, like this:session_start();$_SESSION['logged_in'] = true;And then instead of this:if(!signin($tid))do this:

if (!isset($_SESSION['logged_in']))  $_GET['ac'] = '';if(isset($_SESSION['logged_in']) && !signin($tid))

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...