MySQL doesn't update the row/s -.-
#1

Код:
#define MAX_CNAME 5;
clanData[playerid][cd_cLeader] = 1;
format(clanData[playerid][cd_cName], MAX_CNAME, "%s", inputtext);

mysql_format(gGameConnection, Query, sizeof(Query), "UPDATE `accounts` SET (`cname`, `cleader`) VALUES ('%e', '%i') WHERE `name` = '%e';", inputtext, clanData[playerid][cd_cLeader], ReturnPlayerName(playerid));
mysql_tquery(gGameConnection, Query);
The cmd is working without an AI row but I need the AI row for my player ids. Always if I try to use "WHERE" mysql seems to be not to know where it has to add the data.
Reply
#2

Check your mysql_log, if you can't get it to work post the logs here.
Reply
#3

Your UPDATE syntax is wrong, check this link: https://www.w3schools.com/sql/sql_update.asp
Reply
#4

Quote:
Originally Posted by willbedie
Посмотреть сообщение
Check your mysql_log, if you can't get it to work post the logs here.
Here is the log, there are some errors.

Код:
[21:52:09 09/22/18] [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 '`cleader` = 1, WHERE `id` = 190' at line 1 (Query: "UPDATE `accounts` SET `cname` = '[HUH]' `cleader` = 1, WHERE `id` = 190;")
[21:56:06 09/22/18] [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 '`cleader` = 1, WHERE `id` = 190' at line 1 (Query: "UPDATE `accounts` SET `cname` = '[HUH]' `cleader` = 1, WHERE `id` = 190;")
[22:13:14 09/22/18] [ERROR] CMySQLQuery::Execute[] - (error #1364) Field 'name' doesn't have a default value (Query: "INSERT INTO `accounts` (`cname`, `cleader`) VALUES('[HUH]', '1');")
[22:20:40 09/22/18] [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 'WHERE `id` = 190' at line 1 (Query: "INSERT INTO `accounts` (`cname`, `cleader`) VALUES('[HUH]', '1') WHERE `id` = 190;")
[22:45:19 09/22/18] [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 '(`cname`, `cleader`) VALUES ('HUH', '1') WHERE `name` = 'testaccount89'' at line 1 (Query: "UPDATE `accounts` SET (`cname`, `cleader`) VALUES ('HUH', '1') WHERE `name` = 'testaccount89';")
Reply
#5

PHP код:
UPDATE `accountsSET `cname` = '%e', `cleader` = '%i' WHERE `name` = '%e';", inputtext, clanData[playerid][cd_cLeader], ReturnPlayerName(playerid)); 
Reply
#6

Quote:
Originally Posted by willbedie
Посмотреть сообщение
PHP код:
UPDATE `accountsSET `cname` = '%e', `cleader` = '%i' WHERE `name` = '%e';", inputtext, clanData[playerid][cd_cLeader], ReturnPlayerName(playerid)); 
Spoon feeding isn't helping.

@Doddinger: Funny how you completely ignore my reply because people like you expect everything done for you free here, and they get it.
Reply
#7

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Spoon feeding isn't helping.

@Doddinger: Funny how you completely ignore my reply because people like you expect everything done for you free here, and they get it.
That's not really spoon feeding since your reply explained everything and I just posted the code, he could understand it from your reply I guess, the code was just an example.
Reply
#8

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Your UPDATE syntax is wrong, check this link: https://www.w3schools.com/sql/sql_update.asp
Ok, the log says the same thing. I try to fix it. Well, I can't use the UPDATE function...because it is only for existing records? Did this mean that there must be a row with content or did it mean that the row has to be there without even any content?

Maybe this is easier to understand:

1. UPDATE I need a row with existing content or I can not update anything!
2. UPDATE I simply need a row without any existing content. I can also write new data in an empty row!
Reply
#9

You need to update an existing row, if the row you're trying to update doesn't exist then how do you expect to write data in a empty row?
Reply
#10

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Spoon feeding isn't helping.

@Doddinger: Funny how you completely ignore my reply because people like you expect everything done for you free here, and they get it.
Gammix the forum said me that I have to wait 120 seconds before making a new reply. I want to understand it. Maybe the samp-forum got this reputation in your opinion but I'm one of the people which is trying to understand things by myself
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)