PDA

View Full Version : MYSQL Problems..


LikeNPC
15/02/2017, 09:40 AM
I already has this fields but MYSQL still show this error..
please help..

sorry for my bad English

new query[128];
for(new i=0; i<=511; i++)
{
mysql_format(mysql, query, sizeof(query), "SELECT `v_id` FROM `vehicles` WHERE `v_carid` = %d LIMIT 1", i);
mysql_tquery(mysql, query, "loadVehicleData", "i", i);

printf("%s", query);
}


forward loadVehicleData(i);
public loadVehicleData(i)
{
new str[32];
new j=0;
vehicleData[i][vID] = cache_get_field_content_int(j, "v_id");

vehicleData[i][vModel] = cache_get_field_content_int(j, "v_model");
vehicleData[i][vHealth] = cache_get_field_content_float(j, "v_health");

vehicleData[i][vLocationX] = cache_get_field_content_float(j, "v_locationx");
vehicleData[i][vLocationY] = cache_get_field_content_float(j, "v_locationy");
vehicleData[i][vLocationZ] = cache_get_field_content_float(j, "v_locationz");

vehicleData[i][vAngle] = cache_get_field_content_float(j, "v_angle");
vehicleData[i][vModel] = cache_get_field_content_int(j, "v_model");

vehicleData[i][vGas] = cache_get_field_content_int(j, "v_gas");
vehicleData[i][vEngine] = cache_get_field_content_int(j, "v_engine");
vehicleData[i][vDoors] = cache_get_field_content_int(j, "v_doors");
vehicleData[i][vKeys] = cache_get_field_content_int(j, "v_keys");

for(new b=0; b<sizeof(itemData); b++)
{
format(str, sizeof(str),"vitem_%d",b);
vehicleItem[i][b] = cache_get_field_content_int(j, str);
}


return 1;
}


[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("v_model")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("v_health")
[19:32:54] [ERROR] cache_get_field_content_float - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("v_locationx")
[19:32:54] [ERROR] cache_get_field_content_float - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("v_locationy")
[19:32:54] [ERROR] cache_get_field_content_float - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("v_locationz")
[19:32:54] [ERROR] cache_get_field_content_float - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("v_angle")
[19:32:54] [ERROR] cache_get_field_content_float - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("v_model")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("v_gas")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("v_engine")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("v_doors")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("v_keys")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_0")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_1")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_2")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_3")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_4")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_5")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_6")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_7")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_8")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_9")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_10")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_11")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_12")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_13")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_14")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_15")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_16")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_17")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_18")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype
[19:32:54] [WARNING] CMySQLResult::GetRowDataByName - field not found ("vitem_19")
[19:32:54] [ERROR] cache_get_field_content_int - invalid datatype

X337
15/02/2017, 09:46 AM
You only select v_id field.

SELECT `v_id` FROM `vehicles` WHERE `v_carid` = %d LIMIT 1

Change it into:

SELECT * FROM `vehicles` WHERE `v_carid` = %d LIMIT 1

LikeNPC
15/02/2017, 09:55 AM
I tried this code and mysql show another error to me

[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_float - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_float - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_float - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_float - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_float - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:31] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:32] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:32] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:32] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:32] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:32] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:32] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:32] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:32] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:32] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:32] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:32] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:32] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:32] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:32] [ERROR] cache_get_field_content_int - invalid datatype
[19:47:32] [ERROR] cache_get_field_content_int - invalid datatype

Vince
15/02/2017, 10:27 AM
Don't treat SQL like a dirty file system. You can fetch more than one row at a time. That's the point. Sending a separate query for each row is a massive waste of resources. Instead of looping over queries and fetching one result at a time, send one query and then loop over the results.

Runn3R
15/02/2017, 10:41 AM
And v_item%d is just wrong.

Check the tutorial here made by Vince: http://forum.sa-mp.com/showthread.php?t=420363