A_MYSQL Issue -
UnknownGamer - 30.09.2013
pawn Код:
new string2[500];
format(string2, sizeof(string2),"UPDATE `ownedcars` SET Model = '%d', Location_X = '%f', Location_Y = '%f'
, Location_Z = '%f', Angle = '%f', Color_1 = '%d', Color_2 = '%d', Owner = '%s', PlateSet = '%d', Plate = '%s'
, Owned = '%d', Locked = '%d', Paintjob = '%d', Virtualworld = '%d', Component0 = '%d', Component1 = '%d'
, Component2 = '%d', Component3 = '%d', Component4 = '%d', Component5 = '%d', Component6 = '%d', Component7 = '%d'
, Component8 = '%d', Component9 = '%d', Component10 = '%d', Component11 = '%d', Component12 = '%d', Component13 = '%d'
, SecurityCode = '%d'", CarInfo[idx][cModel], CarInfo[idx][cLocationx], CarInfo[idx][cLocationy], CarInfo[idx][cLocationz],
CarInfo[idx][cAngle], CarInfo[idx][cColorOne], CarInfo[idx][cColorTwo], CarInfo[idx][cOwner], CarInfo[idx][cPlateSet],
CarInfo[idx][cPlate], CarInfo[idx][cOwned], CarInfo[idx][cLock], CarInfo[idx][cPaintjob], CarInfo[idx][cVirWorld],
CarInfo[idx][cComponent0], CarInfo[idx][cComponent1], CarInfo[idx][cComponent2], CarInfo[idx][cComponent3], CarInfo[idx][cComponent4],
CarInfo[idx][cComponent5], CarInfo[idx][cComponent6], CarInfo[idx][cComponent7], CarInfo[idx][cComponent8], CarInfo[idx][cComponent9],
CarInfo[idx][cComponent10], CarInfo[idx][cComponent11], CarInfo[idx][cComponent12], CarInfo[idx][cComponent13], CarInfo[idx][cCode]);
mysql_query(string2);
Okay so after reading about saving SQL querys to a database, what did I do wrong there, looks fine to me?
pawn Код:
error 037: invalid string (possibly non-terminated string)
error 017: undefined symbol "UPDATE"
Re: A_MYSQL Issue -
BlackBank - 30.09.2013
Quote:
Originally Posted by UnknownGamer
pawn Код:
new string2[500]; format(string2, sizeof(string2),"UPDATE `ownedcars` SET Model = '%d', Location_X = '%f', Location_Y = '%f' , Location_Z = '%f', Angle = '%f', Color_1 = '%d', Color_2 = '%d', Owner = '%s', PlateSet = '%d', Plate = '%s' , Owned = '%d', Locked = '%d', Paintjob = '%d', Virtualworld = '%d', Component0 = '%d', Component1 = '%d' , Component2 = '%d', Component3 = '%d', Component4 = '%d', Component5 = '%d', Component6 = '%d', Component7 = '%d' , Component8 = '%d', Component9 = '%d', Component10 = '%d', Component11 = '%d', Component12 = '%d', Component13 = '%d' , SecurityCode = '%d'", CarInfo[idx][cModel], CarInfo[idx][cLocationx], CarInfo[idx][cLocationy], CarInfo[idx][cLocationz], CarInfo[idx][cAngle], CarInfo[idx][cColorOne], CarInfo[idx][cColorTwo], CarInfo[idx][cOwner], CarInfo[idx][cPlateSet], CarInfo[idx][cPlate], CarInfo[idx][cOwned], CarInfo[idx][cLock], CarInfo[idx][cPaintjob], CarInfo[idx][cVirWorld], CarInfo[idx][cComponent0], CarInfo[idx][cComponent1], CarInfo[idx][cComponent2], CarInfo[idx][cComponent3], CarInfo[idx][cComponent4], CarInfo[idx][cComponent5], CarInfo[idx][cComponent6], CarInfo[idx][cComponent7], CarInfo[idx][cComponent8], CarInfo[idx][cComponent9], CarInfo[idx][cComponent10], CarInfo[idx][cComponent11], CarInfo[idx][cComponent12], CarInfo[idx][cComponent13], CarInfo[idx][cCode]); mysql_query(string2);
Okay so after reading about saving SQL querys to a database, what did I do wrong there, looks fine to me?
pawn Код:
error 037: invalid string (possibly non-terminated string) error 017: undefined symbol "UPDATE"
|
You break the string value in format (New line in a string).
You can fix it by adding a backslash '\' after your line.
So your code will be:
pawn Код:
new string2[500];
format(string2, sizeof(string2),"UPDATE `ownedcars` SET Model = '%d', Location_X = '%f', Location_Y = '%f' \
, Location_Z = '%f', Angle = '%f', Color_1 = '%d', Color_2 = '%d', Owner = '%s', PlateSet = '%d', Plate = '%s' \
, Owned = '%d', Locked = '%d', Paintjob = '%d', Virtualworld = '%d', Component0 = '%d', Component1 = '%d' \
, Component2 = '%d', Component3 = '%d', Component4 = '%d', Component5 = '%d', Component6 = '%d', Component7 = '%d' \
, Component8 = '%d', Component9 = '%d', Component10 = '%d', Component11 = '%d', Component12 = '%d', Component13 = '%d' \
, SecurityCode = '%d'", CarInfo[idx][cModel], CarInfo[idx][cLocationx], CarInfo[idx][cLocationy], CarInfo[idx][cLocationz],
CarInfo[idx][cAngle], CarInfo[idx][cColorOne], CarInfo[idx][cColorTwo], CarInfo[idx][cOwner], CarInfo[idx][cPlateSet],
CarInfo[idx][cPlate], CarInfo[idx][cOwned], CarInfo[idx][cLock], CarInfo[idx][cPaintjob], CarInfo[idx][cVirWorld],
CarInfo[idx][cComponent0], CarInfo[idx][cComponent1], CarInfo[idx][cComponent2], CarInfo[idx][cComponent3], CarInfo[idx][cComponent4],
CarInfo[idx][cComponent5], CarInfo[idx][cComponent6], CarInfo[idx][cComponent7], CarInfo[idx][cComponent8], CarInfo[idx][cComponent9],
CarInfo[idx][cComponent10], CarInfo[idx][cComponent11], CarInfo[idx][cComponent12], CarInfo[idx][cComponent13], CarInfo[idx][cCode]);
mysql_query(string2);
Re: A_MYSQL Issue -
UnknownGamer - 30.09.2013
Quote:
Originally Posted by BlackBank3
You break the string value in format (New line in a string).
You can fix it by adding a backslash '\' after your line.
So your code will be:
pawn Код:
new string2[500]; format(string2, sizeof(string2),"UPDATE `ownedcars` SET Model = '%d', Location_X = '%f', Location_Y = '%f' \ , Location_Z = '%f', Angle = '%f', Color_1 = '%d', Color_2 = '%d', Owner = '%s', PlateSet = '%d', Plate = '%s' \ , Owned = '%d', Locked = '%d', Paintjob = '%d', Virtualworld = '%d', Component0 = '%d', Component1 = '%d' \ , Component2 = '%d', Component3 = '%d', Component4 = '%d', Component5 = '%d', Component6 = '%d', Component7 = '%d' \ , Component8 = '%d', Component9 = '%d', Component10 = '%d', Component11 = '%d', Component12 = '%d', Component13 = '%d' \ , SecurityCode = '%d'", CarInfo[idx][cModel], CarInfo[idx][cLocationx], CarInfo[idx][cLocationy], CarInfo[idx][cLocationz], CarInfo[idx][cAngle], CarInfo[idx][cColorOne], CarInfo[idx][cColorTwo], CarInfo[idx][cOwner], CarInfo[idx][cPlateSet], CarInfo[idx][cPlate], CarInfo[idx][cOwned], CarInfo[idx][cLock], CarInfo[idx][cPaintjob], CarInfo[idx][cVirWorld], CarInfo[idx][cComponent0], CarInfo[idx][cComponent1], CarInfo[idx][cComponent2], CarInfo[idx][cComponent3], CarInfo[idx][cComponent4], CarInfo[idx][cComponent5], CarInfo[idx][cComponent6], CarInfo[idx][cComponent7], CarInfo[idx][cComponent8], CarInfo[idx][cComponent9], CarInfo[idx][cComponent10], CarInfo[idx][cComponent11], CarInfo[idx][cComponent12], CarInfo[idx][cComponent13], CarInfo[idx][cCode]); mysql_query(string2);
|
Still getting the same error
Re: A_MYSQL Issue -
Isolated - 30.09.2013
Either try the first line, before the format on one line, then the format on the bottom, or strcat.
Re: A_MYSQL Issue -
UnknownGamer - 30.09.2013
Quote:
Originally Posted by Isolated
Either try the first line, before the format on one line, then the format on the bottom, or strcat.
|
Okay so I got them to save now and everything else. Just the loading seems to be failing, and I truely have no idea whats wrong, Still a noob, and getting used to SQL, I'd really love any help
pawn Код:
public LoadCar()
{
new row[4000], carid;
for(new idx = 1; idx < sizeof(CarInfo) ; idx++)
{
mysql_query("SELECT * FROM ownedcars");
mysql_store_result();
while(mysql_retrieve_row())
{
mysql_fetch_row(row);
carid ++;
sscanf(row, "p<|>e<ddffffiis[60]ddds[60]dddddddddddddddd>", CarInfo[carid]);
}
mysql_free_result();
}
printf("[MYSQL-DATABASE]: Loaded %d Owned Vehicles.", carid);
return 1;
}
It says there's 0 loaded cars, there's 2 rows of cars in the database.
Any idea why that doesn't load them with the sscanf?
Re: A_MYSQL Issue -
Jefff - 01.10.2013
pawn Код:
row[4000] ?! 500 should be ok or maybe less
public LoadCar()
{
new row[500], carid = 1;
mysql_query("SELECT * FROM ownedcars");
mysql_store_result();
while(mysql_next_row() && carid < sizeof(CarInfo))
{
mysql_fetch_row(row);
sscanf(row, "p<|>e<ddffffiis[60]ddds[60]dddddddddddddddd>", CarInfo[carid]);
carid++;
}
mysql_free_result();
return printf("[MYSQL-DATABASE]: Loaded %d Owned Vehicles.", carid);
}
Re: A_MYSQL Issue -
UnknownGamer - 01.10.2013
Quote:
Originally Posted by Jefff
pawn Код:
row[4000] ?! 500 should be ok or maybe less
public LoadCar() { new row[500], carid = 1; mysql_query("SELECT * FROM ownedcars"); mysql_store_result(); while(mysql_next_row() && carid < sizeof(CarInfo)) { mysql_fetch_row(row); sscanf(row, "p<|>e<ddffffiis[60]ddds[60]dddddddddddddddd>", CarInfo[carid]); carid++; } mysql_free_result(); return printf("[MYSQL-DATABASE]: Loaded %d Owned Vehicles.", carid); }
|
It said I loaded 1 car, theres 2 in the DB
Just tested, cars didn't create. LoadCar(); - Is called on OnGameModeInit.
Re: A_MYSQL Issue -
Jefff - 01.10.2013
Show new CarInfo[What here ?][some enum];
Re: A_MYSQL Issue -
UnknownGamer - 01.10.2013
Quote:
Originally Posted by Jefff
Show new CarInfo[What here ?][some enum];
|
pawn Код:
enum cInfo
{
cModel,
Float:cLocationx,
Float:cLocationy,
Float:cLocationz,
Float:cAngle,
cColorOne,
cColorTwo,
cOwner[MAX_PLAYER_NAME],
cPlate[24],
cPlateSet,
cOwned,
cLock,
cPaintjob,
cVirWorld,
cComponent0,
cComponent1,
cComponent2,
cComponent3,
cComponent4,
cComponent5,
cComponent6,
cComponent7,
cComponent8,
cComponent9,
cComponent10,
cComponent11,
cComponent12,
cComponent13,
cCode
};
new CarInfo[600][cInfo];
Re: A_MYSQL Issue -
Jefff - 01.10.2013
Try now and show log
pawn Код:
public LoadCar()
{
new row[500], carid = 1;
mysql_query("SELECT * FROM ownedcars");
mysql_store_result();
print("1");
while(mysql_next_row() && carid < sizeof(CarInfo))
{
printf("carid: %d",carid);
mysql_fetch_row(row);
sscanf(row, "p<|>e<iffffiis[" #MAX_PLAYER_NAME "]s[" #MAX_PLAYER_NAME "]iiiiiiiiiiiiiiiiiiii>", CarInfo[carid]);
carid++;
}
print("2");
mysql_free_result();
return printf("[MYSQL-DATABASE]: Loaded %d Owned Vehicles.", carid);
}