SQL Error -
UnknownGamer - 24.05.2013
pawn Код:
public LoadCar()
{
new file[26];
for(new idx = 1; idx < sizeof(CarInfo) ; idx++)
{
format(file, sizeof(file),"SELECT * from `ownedcars`", idx)
mysql_query(file);
CarInfo[idx][cModel] = mysql_fetch_field_row("Model", file);
Error I'm getting is,
pawn Код:
[02:11:25] >> mysql_query( Connection handle: 1 )
[02:11:25] CMySQLHandler::Query(SELECT * from `ownedcars`) - Successfully executed.
[02:11:25] >> mysql_fetch_field_row( Connection handle: 1 )
[02:11:25] CMySQLHandler::FetchField(SELECT * from `ownedcars`) - You cannot call this function now. (Reason: Fields/Rows are empty.)
I've managed to get all the other SQL stuff loaded/done, just now the cars don't load, and thats why... LoadCar() isn't functioning. What did I do wrong?
Re: SQL Error -
Hernando - 24.05.2013
pawn Код:
public LoadCar()
{
new file[26];
for(new idx = 1; idx < sizeof(CarInfo) ; idx++)
{
format(file, sizeof(file),"SELECT * from `ownedcars` WHERE `id`=%d LIMIT 1;", idx)
mysql_query(file);
mysql_store_result();
CarInfo[idx][cModel] = mysql_fetch_field_row("Model", file);
You can change the `id` to whatever you have registering the ID of whichever owneed car it is.
Re: SQL Error -
UnknownGamer - 24.05.2013
Cars dont spawn at all now.
pawn Код:
public LoadCar()
{
new file[26], query[256];
for(new idx = 1; idx < sizeof(CarInfo) ; idx++)
{
format(file, sizeof(file),"SELECT * from `ownedcars` WHERE `id`=%d LIMIT 1;", idx)
mysql_query(file);
mysql_store_result();
CarInfo[idx][cModel] = mysql_fetch_field_row("Model", file);
CarInfo[idx][cLocationx] = mysql_get_field("Location_X", file);
CarInfo[idx][cLocationy] = mysql_get_field("Location_Y", file);
CarInfo[idx][cLocationz] = mysql_get_field("Location_Z", file);
CarInfo[idx][cAngle] = mysql_get_field("Angle", file);
CarInfo[idx][cColorOne] = mysql_get_field("Color_1", file);
CarInfo[idx][cColorTwo] = mysql_get_field("Color_2", file);
CarInfo[idx][cOwner] = mysql_get_field("Owner", file);
CarInfo[idx][cOwned] = mysql_get_field("Owned", file);
CarInfo[idx][cLock] = mysql_get_field("Locked", file);
CarInfo[idx][cPaintjob] = mysql_get_field("Paintjob", file);
CarInfo[idx][cVirWorld] = mysql_get_field("VirtualWorld", file);
CarInfo[idx][cComponent0] = mysql_get_field("Component0", file);
CarInfo[idx][cComponent1] = mysql_get_field("Component1", file);
CarInfo[idx][cComponent2] = mysql_get_field("Component2", file);
CarInfo[idx][cComponent3] = mysql_get_field("Component3", file);
CarInfo[idx][cComponent4] = mysql_get_field("Component4", file);
CarInfo[idx][cComponent5] = mysql_get_field("Component5", file);
CarInfo[idx][cComponent6] = mysql_get_field("Component6", file);
CarInfo[idx][cComponent7] = mysql_get_field("Component7", file);
CarInfo[idx][cComponent8] = mysql_get_field("Component8", file);
CarInfo[idx][cComponent9] = mysql_get_field("Component9", file);
CarInfo[idx][cComponent10] = mysql_get_field("Component10", file);
CarInfo[idx][cComponent11] = mysql_get_field("Component11", file);
CarInfo[idx][cComponent12] = mysql_get_field("Component12", file);
CarInfo[idx][cComponent13] = mysql_get_field("Component13", file);
CarInfo[idx][cCode] = mysql_get_field("SecurityCode", file);
}
print("[MYSQL]: Loaded Cars From Database");
return 1;
}
That's the code I'm currently working with, if any help?
Re: SQL Error -
Hernando - 24.05.2013
which SQL are you using? strickenKid 2.1.1?
Re: SQL Error -
UnknownGamer - 24.05.2013
BlueG's
Re: SQL Error -
Vince - 24.05.2013
Revision?
Re: SQL Error -
UnknownGamer - 24.05.2013
R6, None of the cars in the database are loading, does anyone know why? ^^ With that code above. How ever when I go in-game, and use /vpark, the OnPropUpdate works fine, updates everything, (When I buy a new car that is), till the server is reset, then the cars dont load again?
Re: SQL Error -
UnknownGamer - 24.05.2013
Also tried it like this but no look, anyone know a solution please? Urgent help needed. 0 cars are loading from the database
pawn Код:
public LoadCar()
{
new file[26];
for(new idx = 1; idx < sizeof(CarInfo) ; idx++)
{
format(file, sizeof(file),"SELECT * FROM `ownedcars` WHERE `id`='%d'", idx)
mysql_query(file);
mysql_store_result();
if(mysql_num_rows() != 0)
{
CarInfo[idx][cModel] = mysql_get_field(file,"Model");
CarInfo[idx][cLocationx] = mysql_get_field(file,"Location_X");
CarInfo[idx][cLocationy] = mysql_get_field(file,"Location_Y");
CarInfo[idx][cLocationz] = mysql_get_field(file,"Location_Z");
CarInfo[idx][cAngle] = mysql_get_field(file,"Angle");
CarInfo[idx][cColorOne] = mysql_get_field(file,"Color_1");
CarInfo[idx][cColorTwo] = mysql_get_field(file,"Color_2");
CarInfo[idx][cOwner] = mysql_get_field(file,"Owner");
CarInfo[idx][cOwned] = mysql_get_field(file,"Owned");
CarInfo[idx][cLock] = mysql_get_field(file,"Locked");
CarInfo[idx][cPaintjob] = mysql_get_field(file,"Paintjob");
CarInfo[idx][cVirWorld] = mysql_get_field(file,"VirtualWorld");
CarInfo[idx][cComponent0] = mysql_get_field(file,"Component0");
CarInfo[idx][cComponent1] = mysql_get_field(file,"Component1");
CarInfo[idx][cComponent2] = mysql_get_field(file,"Component2");
CarInfo[idx][cComponent3] = mysql_get_field(file,"Component3");
CarInfo[idx][cComponent4] = mysql_get_field(file,"Component4");
CarInfo[idx][cComponent5] = mysql_get_field(file,"Component5");
CarInfo[idx][cComponent6] = mysql_get_field(file,"Component6");
CarInfo[idx][cComponent7] = mysql_get_field(file,"Component7");
CarInfo[idx][cComponent8] = mysql_get_field(file,"Component8");
CarInfo[idx][cComponent9] = mysql_get_field(file,"Component9");
CarInfo[idx][cComponent10] = mysql_get_field(file,"Component10");
CarInfo[idx][cComponent11] = mysql_get_field(file,"Component11");
CarInfo[idx][cComponent12] = mysql_get_field(file,"Component12");
CarInfo[idx][cComponent13] = mysql_get_field(file,"Component13");
CarInfo[idx][cCode] = mysql_get_field(file,"SecurityCode");
}
mysql_free_result();
}
print("[MYSQL]: Loaded Cars From Database");
return 1;
}
Errors:
pawn Код:
[13:10:30] >> mysql_query( Connection handle: 1 )
[13:10:30] CMySQLHandler::Query(SELECT * FROM `ownedcars`) - Successfully executed.
[13:10:30] >> mysql_store_result( Connection handle: 1 )
[13:10:30] CMySQLHandler::StoreResult() - Result was stored.
[13:10:30] >> mysql_num_rows( Connection handle: 1 )
[13:10:30] CMySQLHandler::NumRows() - Returned 1 row(s)
[13:10:30] >> mysql_fetch_field_row( Connection handle: 1 )
[13:10:30] CMySQLHandler::FetchField(SELECT * FROM `ownedcars`) - You cannot call this function now. (Reason: Fields/Rows are empty.)