MySQL query
#1

pawn Код:
strcat(query, "INSERT INTO `playerdata` (`username`, `password`, `CHAR_CREATED1`, `CHAR_NAME1`, `CHAR_SKINID1`, `CHAR_KI1`, `CHAR_TOTKI1`, ");
    strcat(query, "`CHAR_CREATED2`, `CHAR_NAME2`, `CHAR_SKINID2`, `CHAR_KI2`, `CHAR_TOTKI2`, ");
    strcat(query, "`CHAR_CREATED3`, `CHAR_NAME3`, `CHAR_SKINID3`, `CHAR_KI3`, `CHAR_TOTKI3`, ");
    strcat(query, "`CHAR_CREATED4`, `CHAR_NAME4`, `CHAR_SKINID4`, `CHAR_KI4`, `CHAR_TOTKI4`) ");
    strcat(query, "VALUES ('%s', '%s', '0', 'None', '0', '0', '0', '0', 'None', '0', '0', '0', '0', 'None', '0', '0', '0', '0', 'None', '0', '0', '0')\", PlayerName(playerid), HashStr);");
I had to use strcat, but last values (PlayerName(playerid) and HashStr) are treaded as text. I know I have to change something with quote marks, but I have no idea how do I change it, because I am new to MySQL honestly.

Appreciate any help.
Reply
#2

Use query like here:

pawn Код:
INSERT INTO playerdata VALUES ('%s', '%s', 0, 'None', 0, 0, 0, 0, 'None', 0, 0, 0, 0, 'None', 0, 0, 0, 0, 'None', 0, 0, 0)
And at integers dont use '$1', ' ' is for strings.
Reply
#3

Use default values! You're actually inserting only two real values. Using default values will tremendously shorten your query. Very easy to set up in phpMyAdmin.

Furthermore, only strings should be wrapped in quotes ('). The query will work with quotes around the other values, but MySQL will do an implicite conversion from text to whatever should be in the field. This takes time. A very, very short time, but time nonetheless.

For your original question: just remove the backslash (\).
Reply
#4

Код:
[11:47:34] CMySQLHandler::Query(INSERT INTO playerdata VALUES ('Riddick', '45046CDE2CB147890DC563A8A112A4A3BA20D9B27BAD4AB810BD341C59922991175AC6FAEB9E0BF7C71C7A971A643A5C8586F40FC8E69082361672A4DC7FB3D2', 0, 'None', 0, 0, 0, 0, 'None', 0, 0, 0, 0, 'None', 0, 0, 0, 0, 'None', 0, 0, 0)) - An error has occured. (Error ID: 1136, Column count doesn't match value count at row 1)
edit://
Quote:
Originally Posted by Vince
Посмотреть сообщение
Use default values! You're actually inserting only two real values. Using default values will tremendously shorten your query. Very easy to set up in phpMyAdmin.

Furthermore, only strings should be wrapped in quotes ('). The query will work with quotes around the other values, but MySQL will do an implicite conversion from text to whatever should be in the field. This takes time. A very, very short time, but time nonetheless.

For your original question: just remove the backslash (\).
So, just set them in database? Default values?

edit:\\
Fixed, thanks.
Reply
#5

Yes. In the structure tab you can select any field to be edited. I'm using an older version of phpMyAdmin, but it should look something like this:

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)