SA-MP Forums Archive
Help mysql - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help mysql (/showthread.php?tid=560150)



Help mysql - Edw - 27.01.2015

Hello! How do I check which one to check if the account exists in the database?
I tried this:
PHP код:
                mysql_format(mysqlszQuery128"SELECT * FROM `users` WHERE `Username` = '%s' LIMIT 1;"banname);
                
mysql_query(mysqlszQuery);
                if(
cache_get_row_count(mysql) > 0)
                {
                    
SendClientMessage(playeridCOLOR_GENERAL2"Acest cont (%s) nu exsista in baza de date."banname);
                    return 
1;
                } 
but does not work.
I use mysql r39-2


Re: Help mysql - Edw - 27.01.2015

help me


Re: Help mysql - Edw - 27.01.2015

help?


Re: Help mysql - Ironboy - 27.01.2015

pawn Код:
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `users` WHERE `Username` = '%e' LIMIT 1;", banname);
new Cache:result = mysql_query(mysql, query);
if(cache_get_row_count() > 0)
{
    //if the user exists in database
}
else {
    //If it doesnt exists
     }
cache_delete(result);



Re: Help mysql - Edw - 27.01.2015

How can I find the name written in order?

ban offline command.
PHP код:
new length strlen(cmdtext);
                while ((
idx length) && (cmdtext[idx] <= ' '))
                {
                    
idx++;
                }
                new 
offset idx;
                new 
tmp2[64];
                while ((
idx length) && ((idx offset) < (sizeof(tmp2) - 1)))
                {
                    
tmp2[idx offset] = cmdtext[idx];
                    
idx++;
                }
                
tmp2[idx offset] = EOS;
                if(!
strlen(tmp2)) return SendClientMessage(playeridCOLOR_SERVER"Foloseste: {FFFFFF}/ban [playerid] [motiv]");
                new 
result[64];
                while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
                {
                    
result[idx offset] = cmdtext[idx];
                    
idx++;
                }
                
result[idx offset] = EOS;
                 if(!
strlen(tmp)) return SendClientMessage(playeridCOLOR_SERVER"Foloseste: {FFFFFF}/ban [playerid] [motiv]");
                   new 
name[256];
                
mysql_format(mysqlszQuerysizeof(szQuery), "SELECT * FROM `users` WHERE `Username` = '%e' LIMIT 1;"name);
                new 
Cache:ez mysql_query(mysqlszQuery);
                if(
cache_get_row_count() > 0)
                {
                    
format(szQuerysizeof(szQuery),"UPDATE `users` SET `Banned` = '1' WHERE `Name` = '%s'"giveplayer);
                    
mysql_tquery(mysqlszQuery"" "" );
                    if(
PlayerInfo[playerid][pLanguage] == 1) { format(stringsizeof(string), "%s(offline) a primit ban de la adminul %s, motiv: %s."namesendername, (result)); }
                    else if(
PlayerInfo[playerid][pLanguage] == 2) { format(stringsizeof(string), "%s(offline) was banned from admin %s, reason: %s."namesendername, (result)); }
                    
SendClientMessageToAll(COLOR_CMDstring);
                }
                else
                {
                    
SendClientMessage(playeridCOLOR_GENERAL2"Acest cont (%s) nu exista in baza de date."name);
                }
                
cache_delete(ez); 



Re: Help mysql - Edw - 27.01.2015

Use strcmp.
help please