SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 19/01/2020, 03:19 PM   #1
Vizi10
Huge Clucker
 
Join Date: May 2017
Location: Iran
Posts: 312
Reputation: 8
Default MySQL Query Help

pawn Code:
CountClanMembers(clanid, &dest)
{
    new query[128], Cache:result, rows;
    format(query, sizeof(query), "SELECT COUNT(*) FROM `clans` WHERE `cID` = '%i'", clanid);
    result = mysql_query(1, query); //415
    if(mysql_errno() != 0)
    {
        return printf("Query could not be completed due to error: %s", query);
    }
    cache_get_value_index_int(rows, result, dest); //420
    cache_delete(result);
    return 1;
}
Code:
(415) : warning 213: tag mismatch
(420) : warning 213: tag mismatch
What's problem?
I'm use mysql version R41-4
Vizi10 is offline   Reply With Quote
Old 19/01/2020, 03:31 PM   #2
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,082
Reputation: 174
Default Re: MySQL Query Help

Code:
result = mysql_query(1, query);
should be with correct tag of MySQL:
pawn Code:
result = mysql_query(MySQL: 1, query);
// or
result = mysql_query(MYSQL_DEFAULT_HANDLE, query);
Or you can store the connection handle returned from `mysql_connect` to a variable and use it. It is recommended when using multiple connections to mysql server.

Code:
cache_get_value_index_int(rows, result, dest);
pawn Code:
native cache_get_value_index_int(row_idx, column_idx, &destination);
COUNT() returns only 1 row. Row ids start from 0. There is only one column in SELECT list and column ids start from 0.
pawn Code:
cache_get_value_index_int(0, 0, dest);
__________________
Calisthenics is offline   Reply With Quote
Old 20/01/2020, 05:09 PM   #3
Vizi10
Huge Clucker
 
Join Date: May 2017
Location: Iran
Posts: 312
Reputation: 8
Default Re: MySQL Query Help

Quote:
Originally Posted by Calisthenics View Post
Code:
result = mysql_query(1, query);
should be with correct tag of MySQL:
pawn Code:
result = mysql_query(MySQL: 1, query);
// or
result = mysql_query(MYSQL_DEFAULT_HANDLE, query);
Or you can store the connection handle returned from `mysql_connect` to a variable and use it. It is recommended when using multiple connections to mysql server.

Code:
cache_get_value_index_int(rows, result, dest);
pawn Code:
native cache_get_value_index_int(row_idx, column_idx, &destination);
COUNT() returns only 1 row. Row ids start from 0. There is only one column in SELECT list and column ids start from 0.
pawn Code:
cache_get_value_index_int(0, 0, dest);
Thank you.
Vizi10 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
top 10 query mysql wallen Scripting Help 9 11/03/2018 06:13 PM
[MySQL R39-3] MySQL losing connection during query MEW273 Scripting Help 2 13/04/2015 08:10 AM
MySQL query only updates first letter of column. (BlueG MySQL) Jimmy0wns Scripting Help 1 06/04/2015 12:04 PM
mysql query David94 Scripting Help 7 29/03/2013 03:59 PM
Failed to exeute query. Lost connection to MySQL server during query. *IsBack Help Archive 10 06/01/2011 08:50 AM


All times are GMT. The time now is 06:22 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.