Need help with making a new row to mysql
#1

Hi guys!
I've got some MySQL issiues and I need some help.
I want it to create a new row to MySQL, when I type the command "sultan".
It just does nothing.

The code:
pawn Код:
CMD:sultan(playerid, params[])
{
    new string[128];
    format(string, 128, "INSERT INTO autod (autoid, myygis, omanik, v2rv1, v2rv2, pargitudX, pargitudY, pargitudZ, parkimisangle, model, poesmyygis) VALUES(1, 0, %s, 1, 1, -785.3877, 2753.9294, 45.2800, 235.9695, 411, 0)", playerid);
    mysql_query(string);
    mysql_store_result();
    mysql_free_result();
    return 1;
}
Reply
#2

You forgot the space between VALUES and (
Код:
INSERT INTO autod (autoid, myygis, omanik, v2rv1, v2rv2, pargitudX, pargitudY, pargitudZ, parkimisangle, model, poesmyygis) VALUES (1, 0, %s, 1, 1, -785.3877, 2753.9294, 45.2800, 235.9695, 411, 0)
Also when you insert stuff you don't need mysql_store_result() and mysql_free_result()
Reply
#3

Your also trying to format an int as a string.

replace %s with %d.
Reply
#4

The owner is supposed to be the username of the playerid so I have to use GetPlayerName and it'll remain a string.

omanik = owner
Reply
#5

The playerid is not the players name, get the name and use that in your format line instead of playerid.

EDIT: Don't forget to wrap strings in single quotes. '%s'
Reply
#6

Yea, I'm gonna do it. Missed it before.
Reply
#7

Still doesn't work.

(
pawn Код:
CMD:sultan(playerid, params[])
{
    new string[128], omanikunimi[MAX_PLAYER_NAME];
    GetPlayerName(playerid, omanikunimi, sizeof(omanikunimi));
    format(string, 128, "INSERT INTO autod (autoid, myygis, omanik, v2rv1, v2rv2, pargitudX, pargitudY, pargitudZ, parkimisangle, model, poesmyygis) VALUES (5, 0, 123, 1, 1, -785.3877, 2753.9294, 45.2800, 235.9695, 411, 0)");
    mysql_query(string);
    return 1;
}
)
Reply
#8

Figured it out on my own.
Thanks anyway.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)