SQL Error
#1

I'm beginner programmer.
What the error?

STOCK NEW ID , CREATE VEHICLE :

Quote:

stock JarmuID()
{
new i = 0, idje = 0;
for(;++i < MAX_VEHICLES
{
idje = i;
break;
}
return idje;
}

stock JarmuKeszit(tipus , bool:elado , ar , szin1, szin2, Float:X, Float:Y, Float:Z, Float:Angle)
{
new vdb = JarmuID();
if(vdb > 0)
{
JarmuInfo[vdb][vTulajdonos] = 0;
JarmuInfo[vdb][vTipus] = tipus;
JarmuInfo[vdb][vSzin1] = szin1;
JarmuInfo[vdb][vSzin2] = szin2;
JarmuInfo[vdb][vElado] = elado;
if(elado == true)
{
JarmuInfo[vdb][vAr] = ar;
}
JarmuInfo[vdb][vElet] = 1000.0;
JarmuInfo[vdb][vUzemanyag] = 30;
JarmuInfo[vdb][vPanelek] = 0;
JarmuInfo[vdb][vLampak] = 0;
JarmuInfo[vdb][vAjtok] = 0;
JarmuInfo[vdb][vKerekek] = 0;
JarmuInfo[vdb][vHidraulika] = 0;
JarmuInfo[vdb][vMatrica] = 0;
JarmuInfo[vdb][vFrakcio] = 0;
JarmuInfo[vdb][vZarva] = false;
JarmuInfo[vdb][vX] = X;
JarmuInfo[vdb][vY] = Y;
JarmuInfo[vdb][vZ] = Z;
JarmuInfo[vdb][vAngle] = Angle;

CreateVehicle(tipus, X, Y ,Z , Angle , szin1, szin2, 0);

JarmuInfo[vdb][vID] = cache_insert_id();

new query[128];

mysql_format(kapcsolat, query, sizeof(query), "INSERT INTO `Jarmuvek` (`ID`, `Tulajdonos`, `Tipus`, `Szin1`, `Szin2`, `Elado` ,`Ar`, `Elet`, `Uzemanyag`, `Panelek`, `Lampak` , `Ajtok` , `Kerekek` , `Hidraulika`, `Matrica` , `Frakcio` , `Zar` , `PosX` , `PosY` , `PosZ` , `PosA`) VALUES ('%i', 0, '%i', '%i', '%i', '%i' , 1000, 0, 0 , 0 , 0 , 0, 0 , 0 , 0 , 0 , '%f', '%f', '%f', '%f')", JarmuInfo[vdb][vID], tipus, szin1, szin2, elado , X, Y, Z, Angle);
mysql_tquery(kapcsolat, query, "", "" );

}
}

MYSQL LOG:

Quote:

[10:18:38] [DEBUG] mysql_format - connection: 1, len: 128, format: "INSERT INTO `Jarmuvek` (`ID`, `Tulajdonos`, `Tipus`, `Szin1`, `Szin2`, `Elado` ,`Ar`, `Elet`, `Uzemanyag`, `Panelek`, `Lampak` ,..."
[10:18:38] [ERROR] mysql_format - destination size is too small
[10:18:38] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `Jarmuvek` (`ID`, `Tulajdonos`, `Tipus`, `Szin1`, `S", callback: "(null)", format: "(null)"
[10:18:38] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[10:18:38] [ERROR] CMySQLQuery::Execute[] - (error #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
[10:18:38] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError
[10:18:41] [DEBUG] cache_insert_id - connection: 1
[10:18:41] [WARNING] cache_insert_id - no active cache

Reply
#2

It states the problem:
Quote:

[ERROR] mysql_format - destination size is too small

the size of "query" which is 128 is not enough and learn how to use default values. I suggest you read this thread as well: https://sampforum.blast.hk/showthread.php?tid=609261
Reply
#3

increase query[128] to query[400]
Reply
#4

New error :

Quote:

[18:00:55] [ERROR] CMySQLQuery::Execute[] - (error #1136) Column count doesn't match value count at row 1

Please help.
Reply
#5

The INSERT query has 21 columns and 20 values, they should match otherwise an error will be given.
Reply
#6

New error #2 :

Quote:

[19:13:13] [ERROR] CMySQLQuery::Execute[] - (error #1054) Unknown column '1' in 'field list'

Reply
#7

Would really help if you add this to the script:
pawn Код:
public OnQueryError(errorid, error[], callback[], query[], connectionHandle)
{
    printf("\n\nOnQueryError:\nerror: \"%s\"\nquery: \"%s\"\n\n", error, query);
    return 1;
}
Each time an error is given, it will post both the error and the query in the console/server log.
Reply
#8

WTF?

Quote:

OnQueryError:
error: "Unknown column '1' in 'field list'"
query: "INSERT INTO `Jarmuvek` (`ID`, `Tulajdonos`, `Tipus`, `Szin1`, `Szin2`, `Elado` ,`Ar`, `Elet`, `Uzemanyag`, `Panelek`, `Lampak` , `Ajtok` , `Kerekek` , `Hidraulika`, `Matrica` , `Frakcio` , `Zar` , `PosX` , `PosY` , `PosZ` , `PosA`) VALUES (`1`, 0, `411`, `1`, `1`, `1` , `0` , 1000, 0, 0 , 0 , 0 , 0, 0 , 0 , 0 , 0 , -1971.674, -2378.75, 30.625, 215.133)"

Reply
#9

You have changed the code and you replaced ' with ` in values part - that is wrong. Furthermore, you don't need to use apostrophes or grave accent characters and that reduces the query.

For example:
pawn Код:
INSERT INTO Jarmuvek (ID, Tulajdonos, ..., PosZ , PosA) VALUES (%i, 0, ..., %f, %f)
"..." is supposed to be the text, I cut it off for the sake of demonstration.
Reply
#10

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)