• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Issue with saving players

Gunmetalx

Member
Joined
Sep 13, 2016
Messages
56
Reaction score
8
Im having this issue when i logout of a character. I get this error. Im using Nostalrius 7.7. Ive tried updating the source and recompiling but i ended up throwing it away and starting fresh so Im back to square one. Ive already removed the Werror issue and the Weapons.xml line from the CMakeLists, so it compiled with errors but was successful. Im able to log in but this error is produced when logging out


[Error - mysql_real_query] Query: UPDATE players SET level = 1,group_id = 3,vocation = 0,health = 100,healthmax = 100,experience = 0,lookbody = 106,lookfeet = 95,lookhead = 78,looklegs = 58,looktype = 136,maglevel = 0,mana = 100,manamax = 100,manaspent = 0,`
Message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
[Error - mysql_real_query] Query: UPDATE players SET level = 1,group_id = 3,vocation = 0,health = 100,healthmax = 100,experience = 0,lookbody = 106,lookfeet = 95,lookhead = 78,looklegs = 58,looktype = 136,maglevel = 0,mana = 100,manamax = 100,manaspent = 0,`
Message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
[Error - mysql_real_query] Query: UPDATE players SET level = 1,group_id = 3,vocation = 0,health = 100,healthmax = 100,experience = 0,lookbody = 106,lookfeet = 95,lookhead = 78,looklegs = 58,looktype = 136,maglevel = 0,mana = 100,manamax = 100,manaspent = 0,`
Message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
 
Last edited:
God idk why this worked but it did. I found two other threads that had similar issues and this line of code needed to be changed. If anyone wants to educate me why it works that would be wonderful.

Problem line in iologindata.cpp

LUA:
query << "`sex` = " << player->sex << ',';


Changed it to


LUA:
query << "`sex` = " << static_cast<uint16_t>(player->sex) << ',';
 
God idk why this worked but it did. I found two other threads that had similar issues and this line of code needed to be changed. If anyone wants to educate me why it works that would be wonderful.
The issue is already solved, but I wanted to give some context as to what was causing it:
  • PlayerSex_t is defined as an enum with underlying type uint8_t (sometimes?)
  • uint8_t is an alias to unsigned char (always?)
  • C++ iostreams have a special operator<< overload for char and unsigned char which formats them as characters
  • Enums can be implicitly converted into their underlying type, and since there is no explicit operator<< overload for PlayerSex_t, the overload resolution algorithm selects the one for unsigned char.

Here is a small program to highlight this:
Code:
#include <stdint.h>
#include <iostream>

enum MyEnum: uint8_t {
    A = 65, // 65 is the ascii code for 'A'
    //...
};

int main(int argc, char **argv){
    MyEnum v = A;
    std::cout << "as uint8_t: " << v      << std::endl; // prints A
    std::cout << "as int:     " << (int)v << std::endl; // prints 65
    return 0;
}
 
The issue is already solved, but I wanted to give some context as to what was causing it:
  • PlayerSex_t is defined as an enum with underlying type uint8_t (sometimes?)
  • uint8_t is an alias to unsigned char (always?)
  • C++ iostreams have a special operator<< overload for char and unsigned char which formats them as characters
  • Enums can be implicitly converted into their underlying type, and since there is no explicit operator<< overload for PlayerSex_t, the overload resolution algorithm selects the one for unsigned char.

Here is a small program to highlight this:
Code:
#include <stdint.h>
#include <iostream>

enum MyEnum: uint8_t {
    A = 65, // 65 is the ascii code for 'A'
    //...
};

int main(int argc, char **argv){
    MyEnum v = A;
    std::cout << "as uint8_t: " << v      << std::endl; // prints A
    std::cout << "as int:     " << (int)v << std::endl; // prints 65
    return 0;
}


Thank you for taking the time to write that explanation. Sounds very technical and above my pay grade so ill sit with it for a couple of weeks until i understand it xD
 
Back
Top