MySQL help again
#1

Code:
../gamemodes/Functions.pwn(492) : error 017: undefined symbol "mysql_function_query"
../gamemodes/Functions.pwn(540) : error 017: undefined symbol "mysql_function_query"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Code:
stock LoadApplications()
{
	new query[256];
	for(new i = 1; i < MAX_APPLICATIONS; i++)
	{
		format(query, sizeof(query), "SELECT * FROM applications WHERE ID=%i", i);
		mysql_function_query(mysql, query, true, "LoadApplicationsSQL", "d", i);
	}
	return 1;
}

forward LoadApplicationsSQL(id);
public LoadApplicationsSQL(id)
{
    new fields, rows;
    cache_get_row_count(rows);
	cache_get_field_count(fields);
    if(rows)
    {
        if(ApplicationInfo[id][SentIn] == 0)
    	{
        	new fetch[256];
        	cache_get_value_name(0, "ID", fetch);
			ApplicationInfo[id][ID]= strval(fetch);
        	cache_get_value_name(0, "Name", fetch);
  			format(ApplicationInfo[id][Name], 128, fetch);
  			cache_get_value_name(0, "Question1", fetch);
  			format(ApplicationInfo[id][Question1], 128, fetch);
  			cache_get_value_name(0, "Question2", fetch);
  			format(ApplicationInfo[id][Question2], 128, fetch);
  			cache_get_value_name(0, "Question3", fetch);
  			format(ApplicationInfo[id][Question3], 128, fetch);
  			cache_get_value_name(0, "Question4", fetch);
  			format(ApplicationInfo[id][Question4], 128, fetch);
  			cache_get_value_name(0, "Question5", fetch);
  			format(ApplicationInfo[id][Question5], 128, fetch);
  			cache_get_value_name(0, "Question6", fetch);
  			format(ApplicationInfo[id][Question6], 128, fetch);
  			cache_get_value_name(0, "Accepted", fetch);
			ApplicationInfo[id][AppPassed]= strval(fetch);
			cache_get_value_name(0, "SentIn", fetch);
			ApplicationInfo[id][SentIn]= strval(fetch);
			ApplicationInfo[id][PlayerID] = -1;
		}
	}
	return 1;
}

stock LoadBuildings()
{
	new query[256];
	for(new i = 1; i < MAX_APPLICATIONS; i++)
	{
		format(query, sizeof(query), "SELECT * FROM buildings WHERE ID=%i", i);
		mysql_function_query(mysql, query, true, "LoadBuildingsSQL", "d", i);
	}
	return 1;
}

forward LoadBuildingsSQL(id);
public LoadBuildingsSQL(id)
{
    new fields, rows;
    cache_get_row_count(rows);
	cache_get_field_count(fields);
    if(rows)
    {
   		new fetch[256];
    	cache_get_value_name(0, "ID", fetch);
		BuildingInfo[id][ID]= strval(fetch);
 		cache_get_value_name(0, "Name", fetch);
		format(BuildingInfo[id][Name], 256, fetch);
		cache_get_value_name_float(0, "EnterX", BuildingInfo[id][EnterX]);
		cache_get_value_name_float(0, "EnterY", BuildingInfo[id][EnterY]);
		cache_get_value_name_float(0, "EnterZ", BuildingInfo[id][EnterZ]);
		cache_get_value_name_float(0, "ExitX", BuildingInfo[id][ExitX]);
		cache_get_value_name_float(0, "ExitY", BuildingInfo[id][ExitY]);
		cache_get_value_name_float(0, "ExitZ", BuildingInfo[id][ExitZ]);
		cache_get_value_name_int(0, "Interior", BuildingInfo[id][Int]);
		cache_get_value_name_int(0, "VirtualWorld", BuildingInfo[id][VW]);
		cache_get_value_name_int(0, "FreezeTimer", BuildingInfo[id][FreezeTimer]);
		if(BuildingInfo[id][EnterX] > 0.0) {
		    new string[256];
  			format(string, sizeof(string), "%s\nPress H to enter\nAlso /Enter or /Exit", BuildingInfo[id][Name]);
	    	Build3D[id] = CreateDynamic3DTextLabel(string,0xFFFFFFFF,BuildingInfo[id][EnterX],BuildingInfo[id][EnterY],BuildingInfo[id][EnterZ]+0.75, 25.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1, 100.0);
   			BuildPickup[id] = CreateDynamicPickup(1318, 1, BuildingInfo[id][EnterX],BuildingInfo[id][EnterY],BuildingInfo[id][EnterZ]);
		}
	}
	return 1;
}
Reply
#2

If your version of MYSQL is r40...r41...
Use mysql_tquery
https://sampwiki.blast.hk/wiki/MySQL#mysql_tquery
Reply
#3

Quote:
Originally Posted by Heress
View Post
If your version of MYSQL is r40...r41...
Use mysql_tquery
https://sampwiki.blast.hk/wiki/MySQL#mysql_tquery
building's or applications aren't loading in with the tquery.

Code:
stock LoadBuildings()
{
	new query[256];
	for(new i = 1; i < MAX_APPLICATIONS; i++)
	{
		format(query, sizeof(query), "SELECT * FROM buildings WHERE ID=%i", i);
		mysql_tquery(mysql, query, "LoadBuildingsSQL", "d", i);
	}
	return 1;
}

forward LoadBuildingsSQL(id);
public LoadBuildingsSQL(id)
{
    new fields, rows;
    cache_get_row_count(rows);
	cache_get_field_count(fields);
    if(rows)
    {
   		new fetch[256];
    	cache_get_value_name(0, "ID", fetch);
		BuildingInfo[id][ID]= strval(fetch);
 		cache_get_value_name(0, "Name", fetch);
		format(BuildingInfo[id][Name], 256, fetch);
		cache_get_value_name_float(0, "EnterX", BuildingInfo[id][EnterX]);
		cache_get_value_name_float(0, "EnterY", BuildingInfo[id][EnterY]);
		cache_get_value_name_float(0, "EnterZ", BuildingInfo[id][EnterZ]);
		cache_get_value_name_float(0, "ExitX", BuildingInfo[id][ExitX]);
		cache_get_value_name_float(0, "ExitY", BuildingInfo[id][ExitY]);
		cache_get_value_name_float(0, "ExitZ", BuildingInfo[id][ExitZ]);
		cache_get_value_name_int(0, "Interior", BuildingInfo[id][Int]);
		cache_get_value_name_int(0, "VirtualWorld", BuildingInfo[id][VW]);
		cache_get_value_name_int(0, "FreezeTimer", BuildingInfo[id][FreezeTimer]);
		if(BuildingInfo[id][EnterX] > 0.0) {
		    new string[256];
  			format(string, sizeof(string), "%s\nPress H to enter\nAlso /Enter or /Exit", BuildingInfo[id][Name]);
	    	Build3D[id] = CreateDynamic3DTextLabel(string,0xFFFFFFFF,BuildingInfo[id][EnterX],BuildingInfo[id][EnterY],BuildingInfo[id][EnterZ]+0.75, 25.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1, 100.0);
   			BuildPickup[id] = CreateDynamicPickup(1318, 1, BuildingInfo[id][EnterX],BuildingInfo[id][EnterY],BuildingInfo[id][EnterZ]);
		}
	}
	return 1;
}
It shows up in the database fine, Doesn't load into game but compiling gave me no errors. I type /edit then enter the building ID it says the building doesn't exist in the database. Also the applications aren't loading.
Reply
#4

Anyone help, My buildings and applications show in the database but upon restart all the data in game is blank 0.
Reply
#5

1.
Find:
PHP Code:
cache_get_value_name(0"ID"fetch);
BuildingInfo[id][ID]= strval(fetch); 
Replace with:
PHP Code:
cache_get_value_name_int(0"ID"BuildingInfo[id][ID]); 
2.
Find:
PHP Code:
cache_get_row_count(rows);
cache_get_field_count(fields); 
Replace with:
PHP Code:
cache_get_row_count(rows); 
3.
Just change 0 number to loop rows because you already get the rows so why you must add 0?.

Example:
PHP Code:
cache_get_row_count(rows);
for(new 
irowsi++)
{
      
//do something here
      
cache_get_value_name_int(i"ID"BuildingInfo[id][bID]);

why loop? because you must load all data from rows.
Reply
#6

Quote:
Originally Posted by B3x7K
View Post
1.
Find:
PHP Code:
cache_get_value_name(0"ID"fetch);
BuildingInfo[id][ID]= strval(fetch); 
Replace with:
PHP Code:
cache_get_value_name_int(0"ID"BuildingInfo[id][ID]); 
2.
Find:
PHP Code:
cache_get_row_count(rows);
cache_get_field_count(fields); 
Replace with:
PHP Code:
cache_get_row_count(rows); 
3.
Just change 0 number to loop rows because you already get the rows so why you must add 0?.

Example:
PHP Code:
cache_get_row_count(rows);
for(new 
irowsi++)
{
      
//do something here
      
cache_get_value_name_int(i"ID"BuildingInfo[id][bID]);

why loop? because you must load all data from rows.
Still don't understand might just convert it back to the old MySQL.

changed it now too this but still doesn't load?

Code:
stock LoadApplications()
{
	new query[256];
	for(new i = 1; i < MAX_APPLICATIONS; i++)
	{
		format(query, sizeof(query), "SELECT * FROM applications WHERE ID=%i", i);
		mysql_tquery(mysql, query, "LoadApplicationsSQL", "d", i);
	}
	return 1;
}

forward LoadApplicationsSQL(id);
public LoadApplicationsSQL(id)
{
    new rows;
    cache_get_row_count(rows);
    if(rows)
    {
        if(ApplicationInfo[id][SentIn] == 0)
    	{
        	new fetch[256];
        	cache_get_value_name_int(id, "ID", ApplicationInfo[id][ID]);
        	cache_get_value_name(id, "Name", fetch);
  			format(ApplicationInfo[id][Name], 128, fetch);
  			cache_get_value_name(id, "Question1", fetch);
  			format(ApplicationInfo[id][Question1], 128, fetch);
  			cache_get_value_name(id, "Question2", fetch);
  			format(ApplicationInfo[id][Question2], 128, fetch);
  			cache_get_value_name(id, "Question3", fetch);
  			format(ApplicationInfo[id][Question3], 128, fetch);
  			cache_get_value_name(id, "Question4", fetch);
  			format(ApplicationInfo[id][Question4], 128, fetch);
  			cache_get_value_name(id, "Question5", fetch);
  			format(ApplicationInfo[id][Question5], 128, fetch);
  			cache_get_value_name(id, "Question6", fetch);
  			format(ApplicationInfo[id][Question6], 128, fetch);
  			cache_get_value_name(id, "Accepted", fetch);
			ApplicationInfo[id][AppPassed]= strval(fetch);
			cache_get_value_name(id, "SentIn", fetch);
			ApplicationInfo[id][SentIn]= strval(fetch);
			ApplicationInfo[id][PlayerID] = -1;
		}
	}
	return 1;
}

stock LoadBuildings()
{
	new query[256];
	for(new i = 1; i < MAX_BUILDINGS; i++)
	{
		format(query, sizeof(query), "SELECT * FROM buildings WHERE ID=%i", i);
		mysql_tquery(mysql, query, "LoadBuildingsSQL", "d", i);
	}
	return 1;
}

forward LoadBuildingsSQL(id);
public LoadBuildingsSQL(id)
{
    new rows;
    cache_get_row_count(rows);
    if(rows)
    {
   		new fetch[256];
    	cache_get_value_name_int(0, "ID", BuildingInfo[id][ID]);
 		cache_get_value_name(id, "Name", fetch);
		format(BuildingInfo[id][Name], 256, fetch);
		cache_get_value_name_float(id, "EnterX", BuildingInfo[id][EnterX]);
		cache_get_value_name_float(id, "EnterY", BuildingInfo[id][EnterY]);
		cache_get_value_name_float(id, "EnterZ", BuildingInfo[id][EnterZ]);
		cache_get_value_name_float(id, "ExitX", BuildingInfo[id][ExitX]);
		cache_get_value_name_float(id, "ExitY", BuildingInfo[id][ExitY]);
		cache_get_value_name_float(id, "ExitZ", BuildingInfo[id][ExitZ]);
		cache_get_value_name_int(id, "Interior", BuildingInfo[id][Int]);
		cache_get_value_name_int(id, "VirtualWorld", BuildingInfo[id][VW]);
		cache_get_value_name_int(id, "FreezeTimer", BuildingInfo[id][FreezeTimer]);
		if(BuildingInfo[id][EnterX] > 0.0) {
		    new string[256];
  			format(string, sizeof(string), "%s\nPress H to enter\nAlso /Enter or /Exit", BuildingInfo[id][Name]);
	    	Build3D[id] = CreateDynamic3DTextLabel(string,0xFFFFFFFF,BuildingInfo[id][EnterX],BuildingInfo[id][EnterY],BuildingInfo[id][EnterZ]+0.75, 25.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1, 100.0);
   			BuildPickup[id] = CreateDynamicPickup(1318, 1, BuildingInfo[id][EnterX],BuildingInfo[id][EnterY],BuildingInfo[id][EnterZ]);
		}
	}
	return 1;
}
Reply
#7

Quote:
Originally Posted by TheLeech
View Post
Still don't understand might just convert it back to the old MySQL.

changed it now too this but still doesn't load?

Code:
stock LoadApplications()
{
	new query[256];
	for(new i = 1; i < MAX_APPLICATIONS; i++)
	{
		format(query, sizeof(query), "SELECT * FROM applications WHERE ID=%i", i);
		mysql_tquery(mysql, query, "LoadApplicationsSQL", "d", i);
	}
	return 1;
}

forward LoadApplicationsSQL(id);
public LoadApplicationsSQL(id)
{
    new rows;
    cache_get_row_count(rows);
    if(rows)
    {
        if(ApplicationInfo[id][SentIn] == 0)
    	{
        	new fetch[256];
        	cache_get_value_name_int(id, "ID", ApplicationInfo[id][ID]);
        	cache_get_value_name(id, "Name", fetch);
  			format(ApplicationInfo[id][Name], 128, fetch);
  			cache_get_value_name(id, "Question1", fetch);
  			format(ApplicationInfo[id][Question1], 128, fetch);
  			cache_get_value_name(id, "Question2", fetch);
  			format(ApplicationInfo[id][Question2], 128, fetch);
  			cache_get_value_name(id, "Question3", fetch);
  			format(ApplicationInfo[id][Question3], 128, fetch);
  			cache_get_value_name(id, "Question4", fetch);
  			format(ApplicationInfo[id][Question4], 128, fetch);
  			cache_get_value_name(id, "Question5", fetch);
  			format(ApplicationInfo[id][Question5], 128, fetch);
  			cache_get_value_name(id, "Question6", fetch);
  			format(ApplicationInfo[id][Question6], 128, fetch);
  			cache_get_value_name(id, "Accepted", fetch);
			ApplicationInfo[id][AppPassed]= strval(fetch);
			cache_get_value_name(id, "SentIn", fetch);
			ApplicationInfo[id][SentIn]= strval(fetch);
			ApplicationInfo[id][PlayerID] = -1;
		}
	}
	return 1;
}

stock LoadBuildings()
{
	new query[256];
	for(new i = 1; i < MAX_BUILDINGS; i++)
	{
		format(query, sizeof(query), "SELECT * FROM buildings WHERE ID=%i", i);
		mysql_tquery(mysql, query, "LoadBuildingsSQL", "d", i);
	}
	return 1;
}

forward LoadBuildingsSQL(id);
public LoadBuildingsSQL(id)
{
    new rows;
    cache_get_row_count(rows);
    if(rows)
    {
   		new fetch[256];
    	cache_get_value_name_int(0, "ID", BuildingInfo[id][ID]);
 		cache_get_value_name(id, "Name", fetch);
		format(BuildingInfo[id][Name], 256, fetch);
		cache_get_value_name_float(id, "EnterX", BuildingInfo[id][EnterX]);
		cache_get_value_name_float(id, "EnterY", BuildingInfo[id][EnterY]);
		cache_get_value_name_float(id, "EnterZ", BuildingInfo[id][EnterZ]);
		cache_get_value_name_float(id, "ExitX", BuildingInfo[id][ExitX]);
		cache_get_value_name_float(id, "ExitY", BuildingInfo[id][ExitY]);
		cache_get_value_name_float(id, "ExitZ", BuildingInfo[id][ExitZ]);
		cache_get_value_name_int(id, "Interior", BuildingInfo[id][Int]);
		cache_get_value_name_int(id, "VirtualWorld", BuildingInfo[id][VW]);
		cache_get_value_name_int(id, "FreezeTimer", BuildingInfo[id][FreezeTimer]);
		if(BuildingInfo[id][EnterX] > 0.0) {
		    new string[256];
  			format(string, sizeof(string), "%s\nPress H to enter\nAlso /Enter or /Exit", BuildingInfo[id][Name]);
	    	Build3D[id] = CreateDynamic3DTextLabel(string,0xFFFFFFFF,BuildingInfo[id][EnterX],BuildingInfo[id][EnterY],BuildingInfo[id][EnterZ]+0.75, 25.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1, 100.0);
   			BuildPickup[id] = CreateDynamicPickup(1318, 1, BuildingInfo[id][EnterX],BuildingInfo[id][EnterY],BuildingInfo[id][EnterZ]);
		}
	}
	return 1;
}
Still confused... but let me give you an example how to load some..
PHP Code:

public OnGameModeInit();
{
     
//bla bla bla
     
mysql_tquery(ConnectionHandle"SELECT * FROM `Machines`""Load_Machines");
forward Load_Machines();
public 
Load_Machines()
{
     new 
rows;
     
cache_get_row_count(rows);
     for(new 
irowsi++) if(MAX_MACHINES//loop rows, then check again is i less than MAX_MACHINES
     
{
           
cache_get_value_name_int(i"mID"MachineData[i][MachineID]);
           
cache_get_value_name(i"mName"MachineData[i][MachineName]);
           
//etc
     
}
     return 
1;

Reply
#8

Quote:
Originally Posted by B3x7K
View Post
Still confused... but let me give you an example how to load some..
PHP Code:

public OnGameModeInit();
{
     
//bla bla bla
     
mysql_tquery(ConnectionHandle"SELECT * FROM `Machines`""Load_Machines");
forward Load_Machines();
public 
Load_Machines()
{
     new 
rows;
     
cache_get_row_count(rows);
     for(new 
irowsi++) if(MAX_MACHINES//loop rows, then check again is i less than MAX_MACHINES
     
{
           
cache_get_value_name_int(i"mID"MachineData[i][MachineID]);
           
cache_get_value_name(i"mName"MachineData[i][MachineName]);
           
//etc
     
}
     return 
1;

Still doesn't work even when doing it like that.
Reply
#9

Quote:
Originally Posted by TheLeech
View Post
Still doesn't work even when doing it like that.
Go check your mysql_log.txt and read what errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)