MySQL Problems [REP+]
#1

Hello guys I just created a MySQL system and I am facing some problems, here is my msql's log

Код:
[16:36:50] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT `Password` FROM `playerdata` WHERE `Username` = '%e' LIMIT 1"
[16:36:50] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `Password` FROM `playerdata` WHERE `Username` = 'SecretBo", callback: "OnAccountCheck", format: "i"
[16:36:50] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - starting query execution
[16:36:50] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - query was successfully executed within 0.338 milliseconds
[16:36:50] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[16:36:50] [DEBUG] Calling callback "OnAccountCheck"..
[16:36:50] [DEBUG] cache_get_data - connection: 1
[16:36:50] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[16:36:52] [DEBUG] mysql_format - connection: 1, len: 300, format: "INSERT INTO `playerdata` (`Username`, `Password`, `IP`, `Admin`, `Helper`, `VIP` ,`Money`, `Kills`, `Deaths`) VALUES ('%e', '%s'..."
[16:36:52] [ERROR] mysql_format - destination size is too small
[16:36:52] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `playerdata` (`Username`, `Password`, `IP`, `Admin`,", callback: "OnAccountRegister", format: "i"
[16:36:52] [DEBUG] CMySQLQuery::Execute[OnAccountRegister] - starting query execution
[16:36:52] [ERROR] CMySQLQuery::Execute[OnAccountRegister] - (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 '' at line 1
[16:36:52] [DEBUG] CMySQLQuery::Execute[OnAccountRegister] - error will be triggered in OnQueryError
Register dialog
Код:
public:OnAccountCheck(playerid)
{
	new rows, fields; 
	cache_get_data(rows, fields, mysql);
	if(rows)
	{
		cache_get_field_content(0, "PASS", PlayerData[playerid][pPass], mysql, 129);
		printf("%s", PlayerData[playerid][pPass]);
		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login - "yellow"sbAdmin",""white"Welcome back on "red""SERVER_NAME""white", insert your password bellow\n"white"to login on your account",""yellow"Login","Quit");
	}
	else 
	{
		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Register - "yellow"sbAdmin",""white"Welcome on "red""SERVER_NAME""white", insert your password bellow\n"white"to register an account",""yellow"Register","Quit");
	}
	return 1;
}
When I check my database there is nothing created
Reply
#2

[16:36:52] [ERROR] mysql_format - destination size is too small

That would tell you your destination string is too small for the query. Make it a bit more and see if it solved the problem.
Reply
#3

Quote:
Originally Posted by shadowdog
Посмотреть сообщение
[16:36:52] [ERROR] mysql_format - destination size is too small

That would tell you your destination string is too small for the query. Make it a bit more and see if it solved the problem.
of which column?

- EDIT -

I edited increased it, but still nothing is coming up when I register, any help?

- EDIT -
I fixed it but I am getting another bug now, it updates wrong info

Код:
[17:17:58] [DEBUG] mysql_format - connection: 1, len: 128, format: "UPDATE `playerdata` SET `Admin`=%d, `VIP`=%d, `Money`=%d, `Helper`=%d, `Kills`=%d, `Deaths`=%d"
[17:17:58] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `playerdata` SET `Admin`=51, `VIP`=69, `Money`=69, `Helpe", callback: "(null)", format: "(null)"
[17:17:58] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[17:17:58] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 0.736 milliseconds
[17:17:58] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
Reply
#4

Can you post the format code for that query?
Reply
#5

Quote:
Originally Posted by shadowdog
Посмотреть сообщение
Can you post the format code for that query?
ofc

Код:
stock SaveData(playerid)
{
	new query[128];
	mysql_format(mysql, query, sizeof(query), "UPDATE `playerdata` SET `Admin`=%d, `VIP`=%d, `Money`=%d, `Helper`=%d, `Kills`=%d, `Deaths`=%d",\
	PlayerData[playerid][pAdmin], PlayerData[playerid][pVIP], PlayerData[playerid][pCash], PlayerData[playerid][pHelper], PlayerData[playerid][pKills], PlayerData[playerid][pDeaths]);
	mysql_tquery(mysql, query, "", "");
	return 1;
}
Reply
#6

This
Код:
mysql_tquery(mysql, query, "", "");
To:
Код:
mysql_function_query(mysql, query, false, "", "");
//OR
mysql_query(mysql, query);
Reply
#7

Quote:
Originally Posted by Scott Zulkifli
Посмотреть сообщение
Код:
mysql_function_query(mysql, query, false, "", "");
Not working, finally this problem appears when I press register button
Reply
#8

PHP код:
stock SaveData(playerid)
{
    new 
query[128];
    
mysql_format(mysqlquerysizeof(query), "UPDATE `playerdata` SET `Admin`=%d, `VIP`=%d, `Money`=%d, `Helper`=%d, `Kills`=%d, `Deaths`=%d WHERE #account_id# = %d",\
    
PlayerData[playerid][pAdmin], PlayerData[playerid][pVIP], PlayerData[playerid][pCash], PlayerData[playerid][pHelper], PlayerData[playerid][pKills], PlayerData[playerid][pDeaths], #AccountID#);
    
mysql_tquery(mysqlquery"""");
    return 
1;

Add a WHERE statement to tell the constructor which row should be updated. It should be the account ID or the username, whichever you use.

The mysql_tquery is fine.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)