Jump to content

Query not working


doddsey_65

Recommended Posts

I am using a query to update the db when a user logs in. It sets every value correctly but it doesnt set the colum u_online which is INT(1).

 

$link->query("UPDATE ".TBL_PREFIX."users
                                SET 
                                u_last_login = '".$config['time_now']."',
                                u_online = 1,
                                u_ip = '".$_SERVER['REMOTE_ADDR']."',
                                u_activity_time = '".$config['time_now']."',
                                u_points = u_points + '$login_points'
                                WHERE u_username = '$username'")
                                or die(print_link_error());

 

when i echo the query:

 

UPDATE asf_users 
SET u_last_login = '1300310822',
u_online = 1, 
u_ip = '127.0.0.1', 
u_activity_time = '1300310822', 
u_points = u_points + '1' 
WHERE u_username = 'doddsey65'

 

which works because i tried it in phpmyadmin and it changed the column. But it doesnt work in the actual script. It changes every other value that its supposed to but the u_online.

 

Anyone have any ideas why?

Link to comment
Share on other sites

Do you have another query which sets u_online to 0?  In what circumstances is that other query executed?

 

in login.php i use this to logout the user

 

$link->query("UPDATE ".TBL_PREFIX."users
			SET u_last_login = '".$config['time_now']."',
			u_online = '0'
			WHERE u_username = '$username'")
			or die(print_link_error());

but that only runs if the get value do is present and it = logout

and when they are logging in that value isnt set.

 

if(isset($_GET['do']) && $_GET['do'] == 'logout')

Link to comment
Share on other sites

Ok.. well there are a two main possiblities here:

 

1.  The query you posted is running, and another query changes u_online later

2.  The query you posted is not running, and instead another query is changing the other values.

 

Here's some of the things I would try to debug it:

 

1.  Have the script exit immediately after running the query, and see what u_online is set to

2.  Comment out the query and see if any other code updates the other columns

3.  Comment out all other code which changes u_online and see if u_online is 1 after the script runs.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.