MySQL R40 Error.
#1

Heey'.
I have error messages aand.. I don't know how to solve the problem:
PHP код:
    mysql_query("CREATE TABLE IF NOT EXISTS `Users` (`ID` INTEGER PRIMARY KEY, `Name` VARCHAR(1024) NOT NULL DEFAULT '', `Password` VARCHAR(1024) NOT NULL DEFAULT '', `IP` VARCHAR(1024) NOT NULL DEFAULT '', `Kills` INT NOT NULL DEFAULT '0', `Deaths` INT NOT NULL DEFAULT '0', `Money` INT NOT NULL DEFAULT '0', \
        `Score` INT NOT NULL DEFAULT '0', `Skin` INT NOT NULL DEFAULT '0', `Admin` INT NOT NULL DEFAULT '0', `Health` FLOAT NOT NULL DEFAULT '0.0', `Armor` FLOAT NOT NULL DEFAULT '0.0', `Interior` INT NOT NULL DEFAULT '0', `VirtualWorld` INT NOT NULL DEFAULT '0', `AutoSpawn` INT NOT NULL DEFAULT '0',\
        `AutoLogin` INT NOT NULL DEFAULT '0', `Kick` INT NOT NULL DEFAULT '0', `Ban` INT NOT NULL DEFAULT '0', `Mute` INT NOT NULL DEFAULT '0', `MuteTime` INT NOT NULL DEFAULT '0', `BanTime` INT NOT NULL DEFAULT '0')"
);
// Errormsg
    
mysql_query("CREATE TABLE IF NOT EXISTS `Vehicle` (`ID` INTEGER PRIMARY KEY, `VehicleID` INT NOT NULL DEFAULT '0', `Model` INT NOT NULL DEFAULT '0', `Color1` INT NOT NULL DEFAULT '0', `Color2` INT NOT NULL DEFAULT '0', `Health` FLOAT NOT NULL DEFAULT '0.0', `Plate` VARCHAR(1024) NOT NULL DEFAULT '', \
        `x` FLOAT NOT NULL DEFAULT '0.0', `y` FLOAT NOT NULL DEFAULT '0.0', `z` FLOAT NOT NULL DEFAULT '0.0', `Respawn` INT NOT NULL DEFAULT '0', `Angle` FLOAT NOT NULL DEFAULT '0.0')"
);
    for(new 
iMAX_VEHICLESi++)
    {
        new 
query[200];
        
format(querysizeof(query), "SELECT Model FROM `Vehicle` WHERE VehicleID = %d"i);
        
mysql_query(query);
        
mysql_store_result();
        new 
row mysql_num_rows();
        if(
row)
        {
            
/*
            vStats[i][vSQLIB] = row;
            vStats[i][vX] = mysql_
            vStats[i][vY] = fetch_float("y");
            vStats[i][vZ] = fetch_float("z");
            vStats[i][vColor1] = fetch_int("Color1");
            vStats[i][vColor2] = fetch_int("Color2");
            vStats[i][vHealth] = fetch_float("Health");
            vStats[i][vModel] = fetch_int("Model");
            vStats[i][vRespawn] = fetch_int("Respawn");
            vStats[i][vZr] = fetch_float("Angle");
            fetch_string("Plate", vStats[i][vPlate], 20);
            vStats[i][vID] = CreateVehicle(vStats[i][vModel], vStats[i][vX], vStats[i][vY], vStats[i][vZ], vStats[i][vZr], vStats[i][vColor1], vStats[i][vColor2], vStats[i][vRespawn]);
            SetVehicleHealth(vStats[i][vID], vStats[i][vHealth]);
            SetVehicleNumberPlate(vStats[i][vID], vStats[i][vPlate]);*/
        
}
    } 
»
Код:
newGM.pwn(389) : error 075: input line too long (after substitutions)
newGM.pwn(390) : error 037: invalid string (possibly non-terminated string)
newGM.pwn(390) : error 017: undefined symbol "CREATE"
newGM.pwn(390) : error 017: undefined symbol "IF"
newGM.pwn(390) : fatal error 107: too many error messages on one line
Reply
#2

Use Zeex's compiler patches or split your query up differently. The split up query as you have it will still end up being one huge string on 1 line.
Reply
#3

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
Use Zeex's compiler patches or split your query up differently. The split up query as you have it will still end up being one huge string on 1 line.
Oh.. Okei'. Thanks, I just slit in 3 lines and this is working!
Do you know what is » in MySQL R40 ? :$
PHP код:
        mysql_store_result();
        new 
row mysql_num_rows(); 
Reply
#4

You are referring to non-threaded queries I suppose which you shouldn't be using them. Anyway, mysql_store_result is similar to what mysql_query returns (a cache-id that you delete with cache_delete while you had mysql_free_result in the very old versions). And mysql_num_rows to cache_num_rows.
Reply
#5

This is not loading the database :
PHP код:
    for(new i=1MAX_VEHICLESi++)
    {
        new 
Cache:tempo;
        new 
query[200];
        
format(querysizeof(query), "SELECT ID FROM `Vehicle` WHERE VehicleID = %d"i);
        
tempo mysql_query(MySQLquery);
        new 
row cache_num_rows();
        if(
row 0)
        {
            
cache_get_value_int(0"ID"vStats[i][vSQLIB]);
            
cache_get_value_float(0"x"vStats[i][vX]);
            
cache_get_value_float(0"y"vStats[i][vY]);
            
cache_get_value_float(0"z"vStats[i][vZ]);
            
cache_get_value_int(0"Color1"vStats[i][vColor1]);
            
cache_get_value_int(0"Color2"vStats[i][vColor2]);
            
cache_get_value_float(0"Health"vStats[i][vHealth]);
            
cache_get_value_int(0"Model"vStats[i][vModel]);
            
cache_get_value_int(0"Respawn"vStats[i][vRespawn]);
            
cache_get_value_float(0"Angle"vStats[i][vZr]);
            
cache_get_value(0"Plate"vStats[i][vPlate], 20);

            
vStats[i][vID] = CreateVehicle(vStats[i][vModel], vStats[i][vX], vStats[i][vY], vStats[i][vZ], vStats[i][vZr], vStats[i][vColor1], vStats[i][vColor2], vStats[i][vRespawn]);
            
SetVehicleHealth(vStats[i][vID], vStats[i][vHealth]);
            
SetVehicleNumberPlate(vStats[i][vID], vStats[i][vPlate]);
            
printf("- Vйhicule ID %i created | Stats :"vStats[i][vID]);
            
printf("- x: %f | y: %f | z: %f | Model: %i\nColor 1 & 2: %i & %i | Plate: %s"vStats[i][vX], vStats[i][vY], vStats[i][vZ], vStats[i][vModel], vStats[i][vColor1], vStats[i][vColor2], vStats[i][vPlate]);
        }
        
cache_delete(tempo);
    } 
Reply
#6

Bump
Reply
#7

The query selects only "ID" column and you try to retrieve data from other columns (that are not selected) which will result in errors. There are few things that I'd suggest to use them differently:

- 1 query that selects all rows instead of loop + query over and over again.
- threaded queries over non-threaded queries.
- creating variables out of loops.
- not storing in-game vehicle ID in database.
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The query selects only "ID" column and you try to retrieve data from other columns (that are not selected) which will result in errors. There are few things that I'd suggest to use them differently:

- 1 query that selects all rows instead of loop + query over and over again.
- threaded queries over non-threaded queries.
- creating variables out of loops.
- not storing in-game vehicle ID in database.
Looks like :
PHP код:
    new Cache:tempo,
        
row,
        
query[200];
        
    for(new 
i=1MAX_VEHICLESi++)
    {
        
format(querysizeof(query), "SELECT * FROM `Vehicle` WHERE VehicleID = %d"i);
        
tempo mysql_query(MySQLquery);
        
row cache_num_rows();
        if(
row 0)
        {
            
cache_get_value_int(0"ID"vStats[i][vSQLIB]);
            
cache_get_value_float(0"x"vStats[i][vX]);
            
cache_get_value_float(0"y"vStats[i][vY]);
            
cache_get_value_float(0"z"vStats[i][vZ]);
            
cache_get_value_int(0"Color1"vStats[i][vColor1]);
            
cache_get_value_int(0"Color2"vStats[i][vColor2]);
            
cache_get_value_float(0"Health"vStats[i][vHealth]);
            
cache_get_value_int(0"Model"vStats[i][vModel]);
            
cache_get_value_int(0"Respawn"vStats[i][vRespawn]);
            
cache_get_value_float(0"Angle"vStats[i][vZr]);
            
cache_get_value(0"Plate"vStats[i][vPlate], 20);
            
vStats[i][vID] = CreateVehicle(vStats[i][vModel], vStats[i][vX], vStats[i][vY], vStats[i][vZ], vStats[i][vZr], vStats[i][vColor1], vStats[i][vColor2], vStats[i][vRespawn]);
            
SetVehicleHealth(vStats[i][vID], vStats[i][vHealth]);
            
SetVehicleNumberPlate(vStats[i][vID], vStats[i][vPlate]);
            
printf("- Vйhicule ID %i crйй | Stats :"vStats[i][vID]);
            
printf("- x: %f | y: %f | z: %f | Model: %i\nColor 1 & 2: %i & %i | Plate: %s"vStats[i][vX], vStats[i][vY], vStats[i][vZ], vStats[i][vModel], vStats[i][vColor1], vStats[i][vColor2], vStats[i][vPlate]);
        }
        
cache_delete(tempo);
    } 
I don't understand different other points you mean.
Reply
#9

Does it load the data now?

About the rest:
- "VehicleID" is the in-game vehicle ID, isn't it? All you need is the unique sql ID ("ID" column).
- By threaded queries, I mean mysql_tquery + public function.
- A single query:
PHP код:
// load all vehicles:
mysql_tquery(MySQL"SELECT * FROM Vehicle ORDER BY ID""OnVehiclesLoad""");

forward OnVehiclesLoad();
public 
OnVehiclesLoad()
{
    for (new 
icache_num_rows(); != ji++)
    {
        
cache_get_value_int(i"ID"vStats[i][vSQLIB]);
        
cache_get_value_float(i"x"vStats[i][vX]);
        
cache_get_value_float(i"y"vStats[i][vY]);
        
cache_get_value_float(i"z"vStats[i][vZ]);
        
cache_get_value_int(i"Color1"vStats[i][vColor1]);
        
cache_get_value_int(i"Color2"vStats[i][vColor2]);
        
cache_get_value_float(i"Health"vStats[i][vHealth]);
        
cache_get_value_int(i"Model"vStats[i][vModel]);
        
cache_get_value_int(i"Respawn"vStats[i][vRespawn]);
        
cache_get_value_float(i"Angle"vStats[i][vZr]);
        
cache_get_value(i"Plate"vStats[i][vPlate], 20);

        
vStats[i][vID] = CreateVehicle(vStats[i][vModel], vStats[i][vX], vStats[i][vY], vStats[i][vZ], vStats[i][vZr], vStats[i][vColor1], vStats[i][vColor2], vStats[i][vRespawn]);
        
SetVehicleHealth(vStats[i][vID], vStats[i][vHealth]);
        
SetVehicleNumberPlate(vStats[i][vID], vStats[i][vPlate]);
        
printf("- Vйhicule ID %i crйй | Stats :"vStats[i][vID]);
        
printf("- x: %f | y: %f | z: %f | Model: %i\nColor 1 & 2: %i & %i | Plate: %s"vStats[i][vX], vStats[i][vY], vStats[i][vZ], vStats[i][vModel], vStats[i][vColor1], vStats[i][vColor2], vStats[i][vPlate]);
    }

Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Does it load the data now?

About the rest:
- "VehicleID" is the in-game vehicle ID, isn't it? All you need is the unique sql ID ("ID" column).
- By threaded queries, I mean mysql_tquery + public function.
- A single query:
- Yes is it but I don't know how to get the unique SQL ID.
I think I don't how MySQL works .. -.-'
PHP код:
     new query[800];
     
format(querysizeof(query), "INSERT INTO `users` (`Name`, `ЁPassword`, `IP`, `Kills`, `Deaths`, `Money`, `Score`, `Skin`, `Admin`) VALUES ('%s', '%s', '%s', %i, %i, %i, %i, %i, %i)",
         
GetName(playerid), pAccount[playerid][pPassword], ippAccount[playerid][pKills], pAccount[playerid][pDeath], pAccount[playerid][pMoney], pAccount[playerid][pScore], pAccount[playerid][pSkin], pAccount[playerid][pAdmin]);
     
mysql_query(MySQLquery);
     
format(querysizeof(query), "INSERT INTO `users` (`Health`, `Armor`, `Interior`, `VirtualWorld`, `AutoSpawn`, `AutoLogin`) VALUES (%f, %f, %i, %i, %i, %i)",
         
pAccount[playerid][pHealth], pAccount[playerid][pArmor], pAccount[playerid][pInterior], pAccount[playerid][pVirtualWorld], pAccount[playerid][pAutoSpawn], pAccount[playerid][pAutoLogin]);
     
mysql_query(MySQLquery);
     
format(querysizeof(query), "INSERT INTO `users` (`Kick`, `Ban`, `Mute`, `MuteTime`, `BanTime`) VALUES (%i, %i, %i, %i, %i)"pAccount[playerid][pKick], pAccount[playerid][pBan], pAccount[playerid][pMute], pAccount[playerid][pMuteTime], pAccount[playerid][pBanTime]);
     
mysql_query(MySQLquery); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)