SA-MP Forums Archive
Need help with making a new row to mysql - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help with making a new row to mysql (/showthread.php?tid=398693)



Need help with making a new row to mysql - tsonn1 - 10.12.2012

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;
}



Re: Need help with making a new row to mysql - you10 - 10.12.2012

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()


Re: Need help with making a new row to mysql - iggy1 - 10.12.2012

Your also trying to format an int as a string.

replace %s with %d.


Re: Need help with making a new row to mysql - tsonn1 - 10.12.2012

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


Re: Need help with making a new row to mysql - iggy1 - 10.12.2012

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'


Re: Need help with making a new row to mysql - tsonn1 - 10.12.2012

Yea, I'm gonna do it. Missed it before.


Re: Need help with making a new row to mysql - tsonn1 - 10.12.2012

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;
}
)


Re: Need help with making a new row to mysql - tsonn1 - 10.12.2012

Figured it out on my own.
Thanks anyway.