Raised This Month: $51 Target: $400
 12% 

ask about query


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lexzor
Veteran Member
Join Date: Nov 2020
Old 03-05-2022 , 10:23   ask about query
Reply With Quote #1

hello. i have this code

PHP Code:
public client_disconnected(id)
{
    if(
is_user_logged_in(id))
    {
        new 
szQuery[512];
        
formatex(szQuerycharsmax(szQuery), "UPDATE `%s` SET `is_user_online` = '0' WHERE `email` = '%s'"g_szTables[0], g_UserData[id][szEmail]);
        
SQL_ThreadQuery(g_SqlTuple"FreeHandle"szQuery);
    }
}

public 
FreeHandle(FailStateHandle:QueryszError[], ErrorCodeszData[], iSize)
{
    if(
FailState || ErrorCode)
        
log_amx("^nSQL ERROR: %s^n"szError);

    
SQL_FreeHandle(Query);
}

bool:is_user_logged_in(id)
{
    return 
g_UserData[id][iIsUserLoggedIn] == true false;

the problem is that sometimes somehow the query is not sent to the database and column is_user_online is not updating to 0. how can i be sure the query is sent or how can i be sure the column is updated when player is disconnecting ?

Last edited by lexzor; 03-06-2022 at 09:23.
lexzor is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 03-06-2022 , 04:33   Re: ask about query
Reply With Quote #2

It's not updating because it returns an error, because you pass two string arguments in your szQuery and give only one value:

Code:
"UPDATE `%s` // first param  SET `is_user_online` = '0' WHERE  `email` = '%s'", // second param  g_UserData[id][szEmail] // only one string passed, not two.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 03-06-2022 at 04:34.
Shadows Adi is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 03-06-2022 , 09:23   Re: ask about query
Reply With Quote #3

Sorry, forgot to add it. The problem is still there.
lexzor is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-06-2022 , 11:06   Re: ask about query
Reply With Quote #4

Post everything essential to the problem, such as the Table layout in addition to the whole script.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
lexzor
Veteran Member
Join Date: Nov 2020
Old 03-06-2022 , 11:24   Re: ask about query
Reply With Quote #5

i already posted what is essential to the problem i don t see why i would post a 1800 lines script if my problem is a query that sometimes don't work.
lexzor is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 03-06-2022 , 11:32   Re: ask about query
Reply With Quote #6

Code:
formatex(szQuery, charsmax(szQuery), "UPDATE `%s` SET `is_user_online` = '0' WHERE `email` = ^"%s^";", g_szTables[0], g_UserData[id][szEmail]);

Try this.
Also, any errors in log?
Code:
if(FailState || ErrorCode)         log_amx("^nSQL ERROR: %s^n", szError);
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 03-06-2022 at 11:32.
Shadows Adi is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-06-2022 , 23:00   Re: ask about query
Reply With Quote #7

I'd try what Shadows Adi suggested, as the email address(es) that are causing you issues may contain a ' character(s).

If you haven't done so already, add some logging to your plugin so you can identify which email addresses are causing you problems. (assuming it's not every single email)
__________________
Bugsy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-07-2022 , 05:51   Re: ask about query
Reply With Quote #8

Quote:
Originally Posted by lexzor View Post
i already posted what is essential to the problem i don t see why i would post a 1800 lines script if my problem is a query that sometimes don't work.
How are you so certain that your problem doesn't relay in those 1800 lines.?


Also you don't need to free the handle in the thread function call back, read the documentation carefully.

PHP Code:
public FreeHandle(FailStateHandle:QueryszError[], ErrorCodeszData[], iSize)
{
    if(
FailState || ErrorCode)
    {
        
log_amx("^nSQL ERROR: %s^n"szError);
        return; 
// Always return when there's an error.
     
}

    
SQL_FreeHandle(Query); <---------- Remove this line!

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 03-07-2022 at 07:52.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Old 03-07-2022, 05:52
Natsheh
This message has been deleted by Natsheh.
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode