SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 24/05/2017, 04:16 PM   #1
fatlirmorina
Big Clucker
 
Join Date: Nov 2013
Posts: 70
Reputation: 1
Default SQL Help

Well, I am trying to make an ban system but whatever SQL always occurs errors cos I'm a noobie.

Gimme a hand.
Errors:
Code:
[17:59:41] [ERROR] CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELCET * FROM `bans` WHERE `ip` = '127.0.0.1'' at line 1
[17:59:41] [WARNING] cache_get_row_count - no active cache
[17:59:41] [WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('0')
Script:
Code:
new sql123[500], Cache:result;
	mysql_format(sqldb, sql123, sizeof sql123, "SELCET * FROM `bans` WHERE `ip` = '%s'", plrIP);
 	result = mysql_query(sqldb, sql123);
	if(cache_num_rows())
	{
	    SendClientMessage(playerid, -1, "works");
	}
	cache_delete(result);
fatlirmorina is offline   Reply With Quote
Old 24/05/2017, 04:22 PM   #2
Banditul18
Huge Clucker
 
Join Date: Nov 2014
Location: Brasov,Romania
Posts: 408
Reputation: 32
Default Re: SQL Help

SELCET

to

SELECT
Banditul18 is offline   Reply With Quote
Old 24/05/2017, 04:29 PM   #3
fatlirmorina
Big Clucker
 
Join Date: Nov 2013
Posts: 70
Reputation: 1
Default Re: SQL Help

oh my fucking god, sorry for this. I am so dumb, thanks mate!
fatlirmorina is offline   Reply With Quote
Old 24/05/2017, 05:40 PM   #4
fatlirmorina
Big Clucker
 
Join Date: Nov 2013
Posts: 70
Reputation: 1
Default Re: SQL Help

Needed help again, can someone help me search everything what matches this GPCI? If you get what i mean
Code:
COMMAND:match(playerid, params[])
{
    if(!PlayerInfo[playerid][power]) return SendClientError(playerid, CANT_USE_CMD);
    new emri;
    if(sscanf(params, "u", emri)) return SCP(playerid, "<partofname/playerid>");
	new sql[500], gpcija[64], Cache:result;
	gpci(emri, gpcija, sizeof(gpcija));
	mysql_format(sqldb, sql, sizeof sql, "SELECT * FROM `gpci` WHERE `gpci` = '%s'", gpcija);
	mysql_query(sqldb, sql);
	if(cache_num_rows())
	{
	    new rows = cache_num_rows();
	    for(new i; i<=rows; i++)
	    {
		    new emri1[128];
			cache_get_field_content(0, "name", emri1);
			format(iStr, sizeof(iStr), "{ff0000}%s matches with %s", emri1, PlayerName(emri));
			SendClientMessage(playerid, -1, iStr);
		}
	}
	else
	{
	    SendClientMessage(playerid, -1, "{ff0000}Can't find any!");
	}
	cache_delete(result);
	return 1;
}
fatlirmorina is offline   Reply With Quote
Old 24/05/2017, 05:53 PM   #5
Banditul18
Huge Clucker
 
Join Date: Nov 2014
Location: Brasov,Romania
Posts: 408
Reputation: 32
Default Re: SQL Help

Try like this
PHP Code:
COMMAND:match(playeridparams[])
{
    if(!
PlayerInfo[playerid][power]) return SendClientError(playeridCANT_USE_CMD);
    new 
emri;
    if(
sscanf(params"u"emri)) return SCP(playerid"<partofname/playerid>");
    new 
sql[500], gpcija[64], Cache:result;
    
gpci(emrigpcijasizeof(gpcija));
    
mysql_format(sqldbsqlsizeof sql"SELECT * FROM `gpci` WHERE `gpci` = '%e'"gpcija);
    
result mysql_query(sqldbsql);
    new 
rows cache_num_rows();
    if(
rows 0)
    {
        for(new 
rowrow rowsrow++)
        {
            new 
emri1[128];
            
cache_get_field_content(row"name"emri1);
            
format(iStrsizeof(iStr), "{ff0000}%s matches with %s"emri1PlayerName(emri));
            
SendClientMessage(playerid, -1iStr);
        }
    }
    else
    {
        
SendClientMessage(playerid, -1"{ff0000}Can't find any!");
    }
    
cache_delete(result);
    return 
1;

Banditul18 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



All times are GMT. The time now is 12:05 AM.


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