How to save and Load String. using mysql>? -
MBilal - 22.08.2015
Like this i try to save 2 string Banreason and banadmin
its not saving,....
Код:
pInfo[playerid][BanReason] = reason;
pInfo[playerid][BanAdmin] = ServerBan;
new query[128];
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Ban`=%d ,`BanAdmin`=%s ,`BanReason`=%s WHERE `ID`=%d",\
pInfo[playerid][Banned],pInfo[playerid][BanAdmin],pInfo[playerid][BanReason],pInfo[playerid][PDID]);
mysql_tquery(mysql, query );
I got this Error
[03:52:33] [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 ' Fly hack WHERE `ID`=1' at line 1
and also how i can load that when he connect again BanAdmin string and BanReason string how i can load them?
Re: How to save and Load String. using mysql>? -
ZBits - 22.08.2015
pawn Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Ban`=%i ,`BanAdmin`= '%s' ,`BanReason`= '%s' WHERE `ID`=%i",pInfo[playerid][Banned],pInfo[playerid][BanAdmin],pInfo[playerid][BanReason],pInfo[playerid][PDID]);
And make sure your BanReason and BanAdmin fields are set to
EDIT:
To load those string use the
Код:
cache_get_row feature
Re: How to save and Load String. using mysql>? -
Dokins - 22.08.2015
Additional to the comment above, you're saving the string incorrectly.
pawn Код:
pInfo[playerid][BanReason] = reason;
Change that to:
pawn Код:
strcpy(pInfo[playerid][BanReason], reason, sizeof(pInfo[playerid][BanReason]));
Re: How to save and Load String. using mysql>? -
MBilal - 22.08.2015
Код:
pInfo[playerid][BanAdmin] = cache_get_row(0,37);
pInfo[playerid][BanReason] = cache_get_row(0,38);
I tried to load them like this but getting warnings..
warning 202: number of arguments does not match definition
Re: How to save and Load String. using mysql>? -
Logofero - 22.08.2015
Quote:
Originally Posted by MBilal
Код:
pInfo[playerid][BanAdmin] = cache_get_row(0,37);
pInfo[playerid][BanReason] = cache_get_row(0,38);
I tried to load them like this but getting warnings..
warning 202: number of arguments does not match definition
|
The types of data in the database do not match the type of array
Eixample:
Код:
cache_get_row(0,37) // If return is Float
cache_get_row(0,38) // If return is Integer
pInfo[playerid][BanAdmin] // is integer!
pInfo[playerid][BanReason] // is string[]!
pInfo[playerid][BanReason] != cache_get_row(0,38) // Warring!
Re: How to save and Load String. using mysql>? -
MBilal - 22.08.2015
BanReason[50]
BanAdmin[26] both are strings.
I dont know why its not loading right now.
Re: How to save and Load String. using mysql>? -
Sjn - 22.08.2015
It looks like you are using MySQL R38+, if so, why not simply use cache_get_field_content to fetch the string? It's kinda more easier to use (for me at least)
Код:
native cache_get_field_content(row, const field_name[], destination[], connectionHandle = 1, max_len = sizeof(destination));
Re: How to save and Load String. using mysql>? -
Logofero - 22.08.2015
Quote:
Originally Posted by MBilal
BanReason[50]
BanAdmin[26] both are strings.
I dont know why its not loading right now.
|
If Is string
Try
Код:
format(pInfo[playerid][BanAdmin], sizeof(pInfo[playerid][BanAdmin]), "%s", cache_get_row(0,37));
format(pInfo[playerid][BanReason], sizeof(pInfo[playerid][BanReason]), "%s", cache_get_row(0,38));