MySQL Insert Query Problem
#1

I'm new to BlueG's mysql and i'm using the R5 version of it. I created an insert query to input some things but it wont work. I dont think theres any error.

When i use "SET" instead of "VALUES" ,like this:

Код:
new query[50],pass[50],pName[50];
GetPlayerName(playerid,pName,30);
mysql_real_escape_string(inputtext,pass);
format(query,sizeof(query),"INSERT INTO Users SET Username='%s',Password='%s',Money=10000",pName,pass);
mysql_query(query);
SendClientMessage(playerid,COLOR_YELLOW,"Successfully Registered");
GivePlayerMoney(playerid,10000);
I get this in debug:

Код:
[13:17:45] CMySQLHandler::Query(INSERT INTO Users SET Username='Ron_Killings',Pas) - An error has occured. (Error ID: 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)
And When i use "VALUES" ,like this:

Код:
format(query,sizeof(query),"INSERT INTO Users VALUES ('%s','%s',1000)",pName,pass);
I get this:

Код:
[13:29:10] CMySQLHandler::Query(INSERT INTO Users VALUES('Ron_Killings','main',10) - An error has occured. (Error ID: 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)
Any help?
Reply
#2

Try this!
pawn Код:
new query[50],pass[50],pName[50];
GetPlayerName(playerid,pName,30);
mysql_real_escape_string(inputtext,pass);
format(query,sizeof(query),"INSERT INTO Users SET Username='%s',Password='%s',Money='10000'",pName,pass);
mysql_query(query);
SendClientMessage(playerid,COLOR_YELLOW,"Successfully Registered");
GivePlayerMoney(playerid,10000);
Reply
#3

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
Try this!
pawn Код:
new query[50],pass[50],pName[50];
GetPlayerName(playerid,pName,30);
mysql_real_escape_string(inputtext,pass);
format(query,sizeof(query),"INSERT INTO Users SET Username='%s',Password='%s',Money='10000'",pName,pass);
mysql_query(query);
SendClientMessage(playerid,COLOR_YELLOW,"Successfully Registered");
GivePlayerMoney(playerid,10000);
Nope. I still get this:

Код:
[13:35:16] CMySQLHandler::Query(INSERT INTO Users SET Username='Ron_Killings',Pas) - An error has occured. (Error ID: 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)
Reply
#4

INSERT INTO `users` (Username, Password) VALUES ('%s', '%s')", pName, pass);
Reply
#5

Tell me one thing. MYSQL and SQLite queries are almost same or different?

EDIT: Try what BaubaS told you to!
Reply
#6

Quote:
Originally Posted by BaubaS
Посмотреть сообщение
INSERT INTO `users` (Username, Password) VALUES ('%s', '%s')", pName, pass);
I still get this :/

EDIT: I forgot to shut down the server. Anyway, now i get this:
Код:
[13:43:30] CMySQLHandler::Query(INSERT INTO `users` (Username, Password) VALUES () - An error has occured. (Error ID: 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)
Reply
#7

That's because your query string lenght is too small.. Make it begger
Reply
#8

Quote:
Originally Posted by BaubaS
Посмотреть сообщение
That's because your query string lenght is too small.. Make it begger
Well you are right. Size of Query String was 50 and string was like 70+. Anyway, When i add 1 more column/parameter, 1000 or '1000', it stops working. I dont get any error in debug.txt but it wont just store the result in table.

I've tried:

Код:
format(query,sizeof(query),"INSERT INTO `Users` (Username,Password,Money) VALUES ('%s','%s','1000')",pName,pass);
and this:

Код:
format(query,sizeof(query),"INSERT INTO `Users` (Username,Password,Money) VALUES ('%s','%s',1000)",pName,pass);
Reply
#9

oh, really debug.txt is clear?
Reply
#10

Quote:
Originally Posted by BaubaS
Посмотреть сообщение
oh, really debug.txt is clear?
Yes. No error in debug.txt
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)