MySQL problem
#1

Like it's setting everyone's column the same, the column "TrashMasterMissions"
pawn Код:
static gQuery[60];
    format(gQuery,sizeof gQuery,"UPDATE `Accounts` SET `TrashMasterMissions` = '%i' WHERE `ID` = '%i' LIMIT 1;",PInfo[playerid][TrashMasterMissions],PInfo[playerid][ID]);
    mysql_query(gQuery);
Reply
#2

Quote:
Originally Posted by FireCat
Посмотреть сообщение
Like it's setting everyone's column the same, the column "TrashMasterMissions"
pawn Код:
static gQuery[60];
    format(gQuery,sizeof gQuery,"UPDATE `Accounts` SET `TrashMasterMissions` = '%i' WHERE `ID` = '%i' LIMIT 1;",PInfo[playerid][TrashMasterMissions],PInfo[playerid][ID]);
    mysql_query(gQuery);
pawn Код:
new playerid2;
static gQuery[60];
format(gQuery,sizeof gQuery,"UPDATE `Accounts` SET `TrashMasterMissions` = '%d' WHERE `ID` = '%d' LIMIT 1;",PInfo[playerid][TrashMasterMissions],PInfo[playerid2][ID]);
mysql_query(gQuery);
Reply
#3

Quote:
Originally Posted by Sanady
Посмотреть сообщение
pawn Код:
new playerid2;
static gQuery[60];
format(gQuery,sizeof gQuery,"UPDATE `Accounts` SET `TrashMasterMissions` = '%d' WHERE `ID` = '%d' LIMIT 1;",PInfo[playerid][TrashMasterMissions],PInfo[playerid2][ID]);
mysql_query(gQuery);
Are you joking with me or something?
Doing "new playerid2;" Will assign playerid2 to 0
It will always retrieve the variable of the playerid 0, that makes no sense!
Reply
#4

Quote:
Originally Posted by FireCat
Посмотреть сообщение
Are you joking with me or something?
Doing "new playerid2;" Will assign playerid2 to 0
It will always retrieve the variable of the playerid 0, that makes no sense!
Aha sorry I think you doing command for other ID I didn`t read code good.Sorry
Reply
#5

Quote:
Originally Posted by FireCat
Посмотреть сообщение
Like it's setting everyone's column the same, the column "TrashMasterMissions"
pawn Код:
static gQuery[60];
    format(gQuery,sizeof gQuery,"UPDATE `Accounts` SET `TrashMasterMissions` = '%i' WHERE `ID` = '%i' LIMIT 1;",PInfo[playerid][TrashMasterMissions],PInfo[playerid][ID]);
    mysql_query(gQuery);
For starters the syntax is wrong, I mean, drop the ' around integer values, '' are used to enclose strings, just use %i, or %d. Then print the ID to see if there's anything wrong that might set the same values for every user.
Oh and, stop using static keyword for mysql queries, use new to declare a new variable.
Reply
#6

Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
For starters the syntax is wrong, I mean, drop the ' around integer values, '' are used to enclose strings, just use %i, or %d. Then print the ID to see if there's anything wrong that might set the same values for every user.
Oh and, stop using static keyword for mysql queries, use new to declare a new variable.
No, the syntax is not wrong. To set values you must use '.
And I prefer using static when messing around with strings.
Reply
#7

Quote:
Originally Posted by FireCat
Посмотреть сообщение
No, the syntax is not wrong. To set values you must use '.
And I prefer using static when messing around with strings.
Yeah, it is, you don't use '' for integers, only for strings. And trust me on that, when I used static with mysql queries, things got strange..
Reply
#8

Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
Yeah, it is, you don't use '' for integers, only for strings. And trust me on that, when I used static with mysql queries, things got strange..
I'm not using " for integers, I'm using '
And I found the problem!
It was the size of the variable (cells)
pawn Код:
[17:26:48] CMySQLHandler::Query(UPDATE `Accounts` SET `TrashMasterMissions` = '3' WHERE `ID) - An error has occured. (Error ID: 1054, Unknown column 'ID' in 'where clause')
Reply
#9

Quote:
Originally Posted by FireCat
Посмотреть сообщение
I'm not using " for integers, I'm using '
And I found the problem!
It was the size of the variable (cells)
pawn Код:
[17:26:48] CMySQLHandler::Query(UPDATE `Accounts` SET `TrashMasterMissions` = '3' WHERE `ID) - An error has occured. (Error ID: 1054, Unknown column 'ID' in 'where clause')
Well good for you! Now for the love of Christ, never ever ever put integer value inside single quotes like this:
SELECT * FROM `some_table` WHERE `something` = '1'. NO, you don't do it like that, you never put integers inside single quotes like you do with strings, ask anyone you want. Instead you make it like this: SELECT * FROM `some_table` WHERE `something` = 1
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)