PHP код:
stock LoadBusinesses()
{
for(new BizzID = 0; BizzID < MAX_BUSINESSES; BizzID++)
{
new query[300], savingstring[200], ifnotowned[144], ifisowned[144];
format(query, sizeof(query), "SELECT * FROM Businesses WHERE ID ='%d' LIMIT 1", BizzID);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() != 0)
{
mysql_fetch_row(query);
mysql_fetch_field_row(savingstring, "Price"); BusinessInfo[BizzID][bPrice] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Interior"); BusinessInfo[BizzID][bInterior] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Owned"); BusinessInfo[BizzID][bOwned] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Owner"); BusinessInfo[BizzID][bOwner] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Stored"); BusinessInfo[BizzID][bStored] = strval(savingstring);
mysql_fetch_field_row(savingstring, "X"); BusinessInfo[BizzID][bX] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Y"); BusinessInfo[BizzID][bY] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Z"); BusinessInfo[BizzID][bZ] = strval(savingstring);
mysql_fetch_field_row(savingstring, "EnterX"); BusinessInfo[BizzID][bEnterX] = strval(savingstring);
mysql_fetch_field_row(savingstring, "EnterY"); BusinessInfo[BizzID][bEnterY] = strval(savingstring);
mysql_fetch_field_row(savingstring, "EnterZ"); BusinessInfo[BizzID][bEnterZ] = strval(savingstring);
mysql_fetch_field_row(savingstring, "Level"); BusinessInfo[BizzID][bLevel] = strval(savingstring);
if(BusinessInfo[BizzID][bLevel] == 1)// 24/7
{
format(ifnotowned, sizeof(ifnotowned), "{00FF00}Business ID: {FFFFFF}%d\n{00FF00}Status: {FFFFFF}For Sale\n{00FF00}Price: {FFFFFF}%d$\n{00FF00}Type: {FFFFFF}24/7", BizzID, BusinessInfo[BizzID][bPrice]);
format(ifisowned, sizeof(ifisowned), "{00FF00}Business ID: {FFFFFF}%d\n{00FF00}Owner: {FFFFFF}%s\n{00FF00}Price: {FFFFFF}%d$\n{00FF00}Type: {FFFFFF}24/7", BizzID, BusinessInfo[BizzID][bOwner], BusinessInfo[BizzID][bPrice]);
}
else if(BusinessInfo[BizzID][bLevel] == 2) // Disco
{
format(ifnotowned, sizeof(ifnotowned), "{00FF00}Business ID: {FFFFFF}%d\n{00FF00}Status: {FFFFFF}For Sale\n{00FF00}Price: {FFFFFF}%d$\n{00FF00}Type: {FFFFFF}Disco", BizzID, BusinessInfo[BizzID][bPrice]);
format(ifisowned, sizeof(ifisowned), "{00FF00}Business ID: {FFFFFF}%d\n{00FF00}Owner: {FFFFFF}%s\n{00FF00}Price: {FFFFFF}%d$\n{00FF00}Type: {FFFFFF}Disco", BizzID, BusinessInfo[BizzID][bOwner], BusinessInfo[BizzID][bPrice]);
}
else if(BusinessInfo[BizzID][bLevel] == 3) // Bar
{
format(ifnotowned, sizeof(ifnotowned), "{00FF00}Business ID: {FFFFFF}%d\n{00FF00}Status: {FFFFFF}For Sale\n{00FF00}Price: {FFFFFF}%d$\n{00FF00}Type: {FFFFFF}Bar", BizzID, BusinessInfo[BizzID][bPrice]);
format(ifisowned, sizeof(ifisowned), "{00FF00}Business ID: {FFFFFF}%d\n{00FF00}Owner: {FFFFFF}%s\n{00FF00}Price: {FFFFFF}%d$\n{00FF00}Type: {FFFFFF}Bar", BizzID, BusinessInfo[BizzID][bOwner], BusinessInfo[BizzID][bPrice]);
}
if(BusinessInfo[BizzID][bOwned] == 0)
{
BusinessInfo[BizzID][bPick] = CreatePickup(1318, 1, BusinessInfo[BizzID][bX], BusinessInfo[BizzID][bY], BusinessInfo[BizzID][bZ], 0);
BusinessInfo[BizzID][bLabel] = Create3DTextLabel(ifnotowned, 0xFFFFFFFF, BusinessInfo[BizzID][bX], BusinessInfo[BizzID][bY], BusinessInfo[BizzID][bZ], 25.0, 0, 0);
}
else if(BusinessInfo[BizzID][bOwned] == 1)
{
BusinessInfo[BizzID][bPick] = CreatePickup(1318, 1, BusinessInfo[BizzID][bX], BusinessInfo[BizzID][bY], BusinessInfo[BizzID][bZ], 0);
BusinessInfo[BizzID][bLabel] = Create3DTextLabel(ifisowned, 0xFFFFFFFF, BusinessInfo[BizzID][bX], BusinessInfo[BizzID][bY], BusinessInfo[BizzID][bZ], 25.0, 0, 0);
}
businessid++;
}
}
printf("LOADED BIZZS: %d/%d", businessid, MAX_BUSINESSES);
mysql_free_result();
}
// ----------
no errors and mysql database is working well..
but it doesn't create any business.. i can't find the problem.. help?
What does it say in the console? Does the line 'LOADED BIZZS: xx/xx" show up at all? If it does and there are 0 businesses, then you probably don't have any entries in your SQL database.
Your query only retrieves 1 result from the database.
If you want all of the results to be retrieved, remove the 'LIMIT 1' from the query. If you're testing it with this one business, I advise you to use 'printf' to print out values of the retrieved coordinates. Check if they match the records from your DB.