SA-MP Forums Archive
Forum Name Isn't saving but loads? - 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: Forum Name Isn't saving but loads? (/showthread.php?tid=596872)



Forum Name Isn't saving but loads? - TheLeech - 23.12.2015

Ok so the forum name loads if I make it in the database but doesn't save.

Код:
COMMAND:forumname(playerid, params[])
{
    if (GetPVarInt(playerid, "PlayerLogged") == 0) return SendClientMessage(playerid, COLOR_WHITE, "You must be logged in to use this.");
    new fname[124];
    new query[4096];
    if(sscanf(params, "s[128]", fname)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /forumname [Name]");
    mysql_format(handlesql, query, sizeof(query), "UPDATE `accounts` SET ForumName=%e, WHERE ID=%i", fname, PlayerInfo[playerid][pID]);
	mysql_pquery(handlesql, query);
	mysql_format(handlesql, query, sizeof(query), "SELECT ForumName FROM `accounts` WHERE Name='%e'", PlayerInfo[playerid][pUsername]);
	mysql_pquery(handlesql, query, "OnAccountLoadMain", "d", playerid);
	return 1;
}

forward OnAccountLoadMain(playerid);
public OnAccountLoadMain(playerid)
{
	printf("OnAccountLoadMain is called [ID %i]", playerid);
	cache_get_field_content(0, "ForumName", oocname[playerid], 79);
	printf("Forumname: %s is loaded.", oocname[playerid]);
	return 1;
}



Re: Forum Name Isn't saving but loads? - TwinkiDaBoss - 23.12.2015

PHP код:
cache_get_field_content(0"ForumName"oocname[playerid], CONNECTION HANDLER79); 
Add a connection handler to your get_field_content


Re: Forum Name Isn't saving but loads? - TheLeech - 23.12.2015

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
PHP код:
cache_get_field_content(0"ForumName"oocname[playerid], CONNECTION HANDLER79); 
Add a connection handler to your get_field_content
its also not saving the forum name for some reason.


Re: Forum Name Isn't saving but loads? - TheLeech - 23.12.2015

The error is.

[18:29:56] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' WHERE ID=3' at line 1


Re: Forum Name Isn't saving but loads? - prineside - 23.12.2015

PHP код:
COMMAND:forumname(playeridparams[])
{
    if (
GetPVarInt(playerid"PlayerLogged") == 0) return SendClientMessage(playeridCOLOR_WHITE"You must be logged in to use this.");
    new 
fname[124];
    new 
query[4096];
    if(
sscanf(params"s[128]"fname)) return SendClientMessage(playeridCOLOR_GREY"USAGE: /forumname [Name]");
    
mysql_format(handlesqlquerysizeof(query), "UPDATE `accounts` SET ForumName=%e WHERE ID=%i"fnamePlayerInfo[playerid][pID]); // Remove "," here
    
mysql_pquery(handlesqlquery);
    
mysql_format(handlesqlquerysizeof(query), "SELECT ForumName FROM `accounts` WHERE Name='%e'"PlayerInfo[playerid][pUsername]);
    
mysql_pquery(handlesqlquery"OnAccountLoadMain""d"playerid);
    return 
1;
}

forward OnAccountLoadMain(playerid);
public 
OnAccountLoadMain(playerid)
{
    
printf("OnAccountLoadMain is called [ID %i]"playerid);
    
cache_get_field_content(0"ForumName"oocname[playerid], 79);
    
printf("Forumname: %s is loaded."oocname[playerid]);
    return 
1;




Re: Forum Name Isn't saving but loads? - TheLeech - 23.12.2015

Quote:
Originally Posted by prineside
Посмотреть сообщение
PHP код:
COMMAND:forumname(playeridparams[])
{
    if (
GetPVarInt(playerid"PlayerLogged") == 0) return SendClientMessage(playeridCOLOR_WHITE"You must be logged in to use this.");
    new 
fname[124];
    new 
query[4096];
    if(
sscanf(params"s[128]"fname)) return SendClientMessage(playeridCOLOR_GREY"USAGE: /forumname [Name]");
    
mysql_format(handlesqlquerysizeof(query), "UPDATE `accounts` SET ForumName=%e WHERE ID=%i"fnamePlayerInfo[playerid][pID]); // Remove "," here
    
mysql_pquery(handlesqlquery);
    
mysql_format(handlesqlquerysizeof(query), "SELECT ForumName FROM `accounts` WHERE Name='%e'"PlayerInfo[playerid][pUsername]);
    
mysql_pquery(handlesqlquery"OnAccountLoadMain""d"playerid);
    return 
1;
}
forward OnAccountLoadMain(playerid);
public 
OnAccountLoadMain(playerid)
{
    
printf("OnAccountLoadMain is called [ID %i]"playerid);
    
cache_get_field_content(0"ForumName"oocname[playerid], 79);
    
printf("Forumname: %s is loaded."oocname[playerid]);
    return 
1;

its now saying

19:06:20] [ERROR] CMySQLQuery::Execute[] - (error #1054) Unknown column 'Panda' in 'field list'
[19:06:24] [ERROR] CMySQLQuery::Execute[] - (error #1054) Unknown column 'Panda' in 'field list'
[19:06:28] [ERROR] CMySQLQuery::Execute[] - (error #1054) Unknown column 'Montana' in 'field list'


Re: Forum Name Isn't saving but loads? - Vince - 23.12.2015

Strings (%e) must be enclosed in single quotes (') otherwise they will be treated as a column name, as is so nicely demonstrated above.


Re: Forum Name Isn't saving but loads? - prineside - 23.12.2015

Print "query" variable and check if it's formated with quotes (all strings must be surrounded by single quotes in SQL). If no, then
PHP код:
... SET ForumName='%e' ...