Command and Conquer: Renegade Official Forums - RDF feed
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
It's sad that the only reason I'm posting is because I have a problem. I'm new to making c++ SSGM plugins and MySQL with c++. I'm trying to make a simple "!postnote" command that will add a player's name and message to a table in the database (I know someone is going to say "Why don't you use fstream or another io function?" It's because I want to experiment with databases). At the moment, I've been able to make it connect, but whenever it tries to execute a query, the server crashes. It doesn't seem to have any trouble with connecting to MySQL, I mean, if I use the correct username and password, it works fine, and when it's the incorrect username and password, it tells me there was an error. I only seem to have a problem when I try to execute a query, at which point, the server crashes without adding anything to the database. I also get 7 warnings when I compile it, all coming from "cppconn/exception.h". I made a simple console application using the same stuff and it worked fine. I suppose my first question would be, is it possible to have MySQL in an SSGM plugin? Second would be, is there an obvious reason it is crashing my server? Toggle Spoiler It is the same as the example plugin, except for the following changes. Notes: I changed the "Treat Warnings As Errors" to no (/wx I think) and I removed /analyze because it was causing a warning. I'm using this for the MySQL client library and this for the c++ connector. Compiler: MSVC++ 2008 Express Linked Libraries: mysqlcppconn.lib libmysql.lib Server Folder DLLs: libmysql.dll MSVCP90.dll MSVCR90.dll mysqlcppconn.dll Edited Source: Toggle Spoiler class PostNoteCommand : public ChatCommandClass { void Triggered(int ID,const TokenClass &Text,int ChatType) { /* Text is a tokenized version of the command paramter. Text[1] would get the first word after the command. Text[0] would get everything after the command. Text(3) would get word 3 and everything after it. Text(2,4) would get words 2 through 4. */ try { std::string pName = Get_Player_Name_By_ID(ID); con = driver->connect("tcp://127.0.0.1:3306", "admin", "****word"); // I'm not entirely sure what this does, but I'm guessing that it selects the database. con->setSchema("renegade"); statement = con->createStatement(); std::string query = StrFormat("INSERT INTO messages(name, message) VALUES('%s', '%s')", pName, Text[0]); // Will cause server to crash. //statement->execute(query); // Will cause server to crash. //statement->executeQuery("INSERT INTO messages(name, message) VALUES('tester5', 'testing value')"); } catch(sql::SQLException &e) { Console_Input("msg MySQL query failure..."); // error C2664: 'Console_Input' : cannot convert parameter 1 from 'std::string' to 'const char *' // No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called //Console_Input(StrFormat("ppage %d MySQL Error: %%", ID, e.what())); } delete statement; delete con; } }; ChatCommandRegistrant<PostNoteCommand> PostNoteCommandReg("!postnote", CHATTYPE_ALL, 1, GAMEMODE_ALL); Build Output Window: Toggle Spoiler Compiling... plugin.cpp C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(47) : warning C4251: 'sql::SQLException::sql_state' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'sql::SQLException' with [ _Elem=char, _Traits=std::char_traits, _Ax=std::allocator ] C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(79) : warning C4512: 'sql::SQLException' : assignment operator could not be generated C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(41) : see declaration of 'sql::SQLException' C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(88) : warning C4512: 'sql::MethodNotImplementedException' : assignment operator could not be generated C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(81) : see declaration of 'sql::MethodNotImplementedException' C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(97) : warning C4512: 'sql::InvalidArgumentException' : assignment operator could not be generated C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(90) : see declaration of 'sql::InvalidArgumentException' C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(106) : warning C4512: 'sql::InvalidInstanceException' : assignment operator could not be generated C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(99) : see declaration of 'sql::InvalidInstanceException' C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(116) : warning C4512: 'sql::NonScrollableException' : assignment operator could not be generated C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(109) : see declaration of 'sql::NonScrollableException' .\plugin.cpp(97) : warning C4101: 'e' : unreferenced local variable Linking... Searching libraries Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Finished searching libraries Creating library .\bin/scripts.lib and object .\bin/scripts.exp Searching libraries Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib: Finished searching libraries Generating code Finished generating code Searching libraries Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib: Finished searching libraries Searching libraries Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib: Finished searching libraries Embedding manifest... Creating browse information file... Microsoft Browse Information Maintenance Utility Version 9.00.30729 Copyright (C) Microsoft Corporation. All rights reserved. If I've made a stupid mistake somewhere, please point it out. If you think you might be able to help, but I left something out, let me know and I'll try to post the info. This is bugging me a lot haha. I also have a bad feeling this is the wrong place to post this...
TechnoBulldog wrote on Fri, 16 July 2010 20:48 It's sad that the only reason I'm posting is because I have a problem. I'm new to making c++ SSGM plugins and MySQL with c++. I'm trying to make a simple "!postnote" command that will add a player's name and message to a table in the database (I know someone is going to say "Why don't you use fstream or another io function?" It's because I want to experiment with databases). At the moment, I've been able to make it connect, but whenever it tries to execute a query, the server crashes. It doesn't seem to have any trouble with connecting to MySQL, I mean, if I use the correct username and password, it works fine, and when it's the incorrect username and password, it tells me there was an error. I only seem to have a problem when I try to execute a query, at which point, the server crashes without adding anything to the database. I also get 7 warnings when I compile it, all coming from "cppconn/exception.h". I made a simple console application using the same stuff and it worked fine. I suppose my first question would be, is it possible to have MySQL in an SSGM plugin? Second would be, is there an obvious reason it is crashing my server? Toggle Spoiler It is the same as the example plugin, except for the following changes. Notes: I changed the "Treat Warnings As Errors" to no (/wx I think) and I removed /analyze because it was causing a warning. I'm using this for the MySQL client library and this for the c++ connector. Compiler: MSVC++ 2008 Express Linked Libraries: mysqlcppconn.lib libmysql.lib Server Folder DLLs: libmysql.dll MSVCP90.dll MSVCR90.dll mysqlcppconn.dll Edited Source: Toggle Spoiler class PostNoteCommand : public ChatCommandClass { void Triggered(int ID,const TokenClass &Text,int ChatType) { /* Text is a tokenized version of the command paramter. Text[1] would get the first word after the command. Text[0] would get everything after the command. Text(3) would get word 3 and everything after it. Text(2,4) would get words 2 through 4. */ try { std::string pName = Get_Player_Name_By_ID(ID); con = driver->connect("tcp://127.0.0.1:3306", "admin", "****word"); // I'm not entirely sure what this does, but I'm guessing that it selects the database. con->setSchema("renegade"); statement = con->createStatement(); std::string query = StrFormat("INSERT INTO messages(name, message) VALUES('%s', '%s')", pName, Text[0]); // Will cause server to crash. //statement->execute(query); // Will cause server to crash. //statement->executeQuery("INSERT INTO messages(name, message) VALUES('tester5', 'testing value')"); } catch(sql::SQLException &e) { Console_Input("msg MySQL query failure..."); // error C2664: 'Console_Input' : cannot convert parameter 1 from 'std::string' to 'const char *' // No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called //Console_Input(StrFormat("ppage %d MySQL Error: %%", ID, e.what())); } delete statement; delete con; } }; ChatCommandRegistrant<PostNoteCommand> PostNoteCommandReg("!postnote", CHATTYPE_ALL, 1, GAMEMODE_ALL); Build Output Window: Toggle Spoiler Compiling... plugin.cpp C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(47) : warning C4251: 'sql::SQLException::sql_state' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'sql::SQLException' with [ _Elem=char, _Traits=std::char_traits, _Ax=std::allocator ] C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(79) : warning C4512: 'sql::SQLException' : assignment operator could not be generated C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(41) : see declaration of 'sql::SQLException' C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(88) : warning C4512: 'sql::MethodNotImplementedException' : assignment operator could not be generated C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(81) : see declaration of 'sql::MethodNotImplementedException' C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(97) : warning C4512: 'sql::InvalidArgumentException' : assignment operator could not be generated C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(90) : see declaration of 'sql::InvalidArgumentException' C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(106) : warning C4512: 'sql::InvalidInstanceException' : assignment operator could not be generated C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(99) : see declaration of 'sql::InvalidInstanceException' C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(116) : warning C4512: 'sql::NonScrollableException' : assignment operator could not be generated C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(109) : see declaration of 'sql::NonScrollableException' .\plugin.cpp(97) : warning C4101: 'e' : unreferenced local variable Linking... Searching libraries Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Finished searching libraries Creating library .\bin/scripts.lib and object .\bin/scripts.exp Searching libraries Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib: Finished searching libraries Generating code Finished generating code Searching libraries Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib: Finished searching libraries Searching libraries Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\LIBCMT.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\OLDNAMES.lib: Searching C:\Program Files\Microsoft Visual Studio 9.0\VC\lib\libcpmt.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ws2_32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\user32.lib: Searching C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt\mysqlcppconn.lib: Searching C:\Program Files\MySQL\MySQL Connector C 6.0.2\lib\opt\libmysql.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\kernel32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\gdi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\winspool.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\comdlg32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\advapi32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\shell32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\ole32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\oleaut32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\uuid.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbc32.lib: Searching C:\Program Files\Microsoft SDKs\Windows\v6.0A\\lib\odbccp32.lib: Finished searching libraries Embedding manifest... Creating browse information file... Microsoft Browse Information Maintenance Utility Version 9.00.30729 Copyright (C) Microsoft Corporation. All rights reserved. If I've made a stupid mistake somewhere, please point it out. If you think you might be able to help, but I left something out, let me know and I'll try to post the info. This is bugging me a lot haha. I also have a bad feeling this is the wrong place to post this... Welcome to the forums. =] The FDS can interact with databases, this shouldn't be a problem. Infact, someone called "jnz" (an awesome chap) almost finished a bot that interacted with a database (before he decided to halt development), you can see the bot's code in this release, here: http://www.littlebigsite.co.uk/Misc/Files/Projects.rar Sadly, I do not know much about database interaction and MySQL, so I cannot help much to be honest, although I would if I could... If your console application worked fine, and it is connecting to the database fine, then I think we can assume it's the query itself that's causing an error? I would be keen to see the console applications query... Perhaps you could try a test query that does not rely on the player GameObject's, but just a normal string? I am thinking there might be a possible cause in the below code, because you're using a std string, and it should be converted to a c string. std::string query = StrFormat("INSERT INTO messages(name, message) VALUES('%s', '%s')", pName, Text[0]); Should be: std::string query = StrFormat("INSERT INTO messages(name, message) VALUES('%s', '%s')", pName.c_str(), Text[0]/*may also need to be concerted to a c string?*/); I'm glad you did post this question because it's an excellent thread!
Yes, I believe StrFormat would expect C strings for %s parameters and would crash if you gave it std::string instead. You should also convert Text[0] to a C string. Internally StrFormat simply uses sprintf (or an equivalent of) and expects a character array for the relevant parameter to a %s tag and passing anything other than a char array (c string) would cause a crash.
Pull the sqlite stuff and stacker from jnz's code
yes u can use C++ and mysql i actually infact have finished using the mysql C++ connetor to connect to a database, take a look at this artical http://lstigile.wordpress.com/2009/05/19/using-libmysqld-with-microsoft-visual-c -2008-express/
Wow, thanks for the help! It's working now! I'm also wondering if there is a mysql_real_escape_string function for c++ like there is for PHP. This would help a lot. Also, does anyone have a clue why I get 6 warnings? Warnings: Toggle Spoiler C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(47) : warning C4251: 'sql::SQLException::sql_state' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs to have dll-interface to be used by clients of class 'sql::SQLException' with [ _Elem=char, _Traits=std::char_traits, _Ax=std::allocator ] C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(79) : warning C4512: 'sql::SQLException' : assignment operator could not be generated C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(41) : see declaration of 'sql::SQLException' C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(88) : warning C4512: 'sql::MethodNotImplementedException' : assignment operator could not be generated C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(81) : see declaration of 'sql::MethodNotImplementedException' C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(97) : warning C4512: 'sql::InvalidArgumentException' : assignment operator could not be generated C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(90) : see declaration of 'sql::InvalidArgumentException' C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(106) : warning C4512: 'sql::InvalidInstanceException' : assignment operator could not be generated C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(99) : see declaration of 'sql::InvalidInstanceException' C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(116) : warning C4512: 'sql::NonScrollableException' : assignment operator could not be generated C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn/exception.h(109) : see declaration of 'sql::NonScrollableException' Also, reborn, it was a very simple console application. This was the query in my test console application. statement->execute("INSERT INTO cms_content(alias, body) VALUES('cplusplus', 'does it work?')"); And the queries I posted in my code (both of which now work): std::string query = StrFormat("INSERT INTO messages(name, message) VALUES('%s', '%s')", pName, Text[0]); // Will cause server to crash. //statement->execute(query); // Will cause server to crash. //statement->executeQuery("INSERT INTO messages(name, message) VALUES('tester5', 'testing value')"); But really, thanks for the help everyone! I think this plugin might actually be useful when it's done.
I'm glad you've got it working, welldone! Can I ask what it is you plan to do with this? What are you working on? Anything for rene that needs DB support sounds pretty interesting. What are your plans? /* google this, para phrasing, but from daniweb: mysql_real_escape_string is actually from the MySQL C API, rather than the developers of PHP. The PHP developers created addslashes(). char * S = new char[strlen(m_headerSubject.c_str())*3 +1]; mysql_real_escape_string(conn, S, m_headerSubject.c_str(), m_headerSubject.length()); m_headerSubject = m_headerSubject.assign(S); */
reborn wrote on Sat, 17 July 2010 13:08 I'm glad you've got it working, welldone! Can I ask what it is you plan to do with this? What are you working on? Anything for rene that needs DB support sounds pretty interesting. What are your plans? /* google this, para phrasing, but from daniweb: mysql_real_escape_string is actually from the MySQL C API, rather than the developers of PHP. The PHP developers created addslashes(). char * S = new char[strlen(m_headerSubject.c_str())*3 +1]; mysql_real_escape_string(conn, S, m_headerSubject.c_str(), m_headerSubject.length()); m_headerSubject = m_headerSubject.assign(S); */ I did read something like that, but I can't find the function. I'm guessing it's in a file I haven't included. Originally, I had the idea to use a database because a friend of mine, Sonic (Sonic2876) said he was planning on opening up a few servers, his main focus being a build server. He said he was having issues making "!load" and "!save" in Lua, and I thought that I might be able to do it in c++. However, I've never gone very deep in c++ (my learning level is somewhere around intermediate) and I never got into fstream or any of those functions. I have recently been experimenting with MySQL and php, though, and the first thing I thought of was storing the objects in a database. I figured it would be cleaner and more efficient. However, I am nowhere near ready to make a build server, so I decided to experiment around first. The idea for this plugin came from Cloud, my main server and one I moderate on. DarkOrbit has a lua script for "!postnote" that I think writes to a file, but I'm not entirely sure. I thought that if you wrote it to a database, a simple php script could let you view all of the notes from in game players and clear it relatively easily. If you write it to a file, you have to manually connect the server and find the file, which sounds like a hassle. At the moment, I just need to find a way to prevent injection attacks (which work easier than I expected) and write the php page. Otherwise, I think this simple but useful plugin will be done.
mysql_real_escape_string is in the MySQL library, NOT the c++ connector.... to be honest I am not sure why there IS a c++ connector when you can use the mysql library directly in c++ anyway... The function you want is defined in the MySQL API which is installed alongside MySQL if you select the installation option to do so. You will also need to link to libmysql.dll, which is included with the API. However I doubt that you will have much success mixing and matching the c++ connector with the raw API functions and you may have to convert your existing code to use the API directly (which, to be honest, is more efficient anyway).
danpaul88 wrote on Sat, 17 July 2010 15:00 mysql_real_escape_string is in the MySQL library, NOT the c++ connector.... to be honest I am not sure why there IS a c++ connector when you can use the mysql library directly in c++ anyway... The function you want is defined in the MySQL API which is installed alongside MySQL if you select the installation option to do so. You will also need to link to libmysql.dll, which is included with the API. However I doubt that you will have much success mixing and matching the c++ connector with the raw API functions and you may have to convert your existing code to use the API directly (which, to be honest, is more efficient anyway). I have the C API, but I'm not sure how to use it really. Is there a specific header file I need to include?
mysql.h should be the only header you need to include to use the library, just make sure to also add libmysql.dll to the linker input options.
When I press build after including mysql.h, it has six errors in mysql_com.h, as well as the other six warnings. Toggle Spoiler 1>c:\program files\mysql\mysql connector c 6.0.2\include\mysql_com.h(268) : error C2146: syntax error : missing ';' before identifier 'fd' 1>c:\program files\mysql\mysql connector c 6.0.2\include\mysql_com.h(268) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\program files\mysql\mysql connector c 6.0.2\include\mysql_com.h(268) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\program files\mysql\mysql connector c 6.0.2\include\mysql_com.h(437) : error C2065: 'SOCKET' : undeclared identifier 1>c:\program files\mysql\mysql connector c 6.0.2\include\mysql_com.h(437) : error C2146: syntax error : missing ')' before identifier 's' 1>c:\program files\mysql\mysql connector c 6.0.2\include\mysql_com.h(438) : error C2059: syntax error : ')'
#include "windows.h" using namespace::std; They are what fixed it for me yesterday.
Sladewill wrote on Sun, 18 July 2010 05:15 #include "windows.h" using namespace::std; They are what fixed it for me yesterday. Oh, yeah, that fixes it, I think. I think WIN32_LEAN_AND_MEAN was messing it up, as well as the order it was in. I can access the function now, but I'm trying to find a way to use the c++ connector instead of an open C connection. I have a feeling that's impossible (lol) but I'm going to keep looking for a way. Again, thanks for the help so far everyone! EDIT: I've found out that if you use mysql_escape_string (no real) it doesn't require an open connection, but it also doesn't use the current character set, or whatever that is. http://dev.mysql.com/doc/refman/5.1/en/mysql-escape-string.html Quote: You should use mysql_real_escape_string() instead! This function is identical to mysql_real_escape_string() except that mysql_real_escape_string() takes a connection handler as its first argument and escapes the string according to the current character set. mysql_escape_string() does not take a connection argument and does not respect the current character set.
Why are you against using the connection and query functions in the MySQL API rather than the ones in the C++ connector? Using them directly would be more efficient in the long run, since the C++ connector is doing that internally anyway but adding an extra level between your program and the API. MySQL* db_connection = mysql_init(NULL); mysql_real_connect ( db_connection, "localhost", "username", "password", "schema", NULL, NULL, NULL ); Connecting to a MySQL database using the API is that simple. Anyway, obviously it's up to you to decide which way you prefer but I am still a bit confused why anyone would use the c++ connector when the API works in c++ anyway...
danpaul88 wrote on Sun, 18 July 2010 10:42 Why are you against using the connection and query functions in the MySQL API rather than the ones in the C++ connector? Using them directly would be more efficient in the long run, since the C++ connector is doing that internally anyway but adding an extra level between your program and the API. MySQL* db_connection = mysql_init(NULL); mysql_real_connect ( db_connection, "localhost", "username", "password", "schema", NULL, NULL, NULL ); Connecting to a MySQL database using the API is that simple. Anyway, obviously it's up to you to decide which way you prefer but I am still a bit confused why anyone would use the c++ connector when the API works in c++ anyway... Mostly because I'm stubborn and am not used to the C API. However, I'll look into it if it's as simple as you say lol. I'll look into it later, though, I'm a bit busy right now.
Is the plugin itself creating the database and tables and such, or are you manually creating that first, then allowing the plugin to use it? Is the plugin multi-threaded? Does it need to be? I don't know much about databases at all, really, let alone securing it. Would you need to make it so secure if the database was being access locally on the machine, and was not set-up for remote access to the DB?
reborn wrote on Sun, 18 July 2010 14:20 Is the plugin itself creating the database and tables and such, or are you manually creating that first, then allowing the plugin to use it? Is the plugin multi-threaded? Does it need to be? I don't know much about databases at all, really, let alone securing it. Would you need to make it so secure if the database was being access locally on the machine, and was not set-up for remote access to the DB? No the plugin itself does not create the databases or tables. I'm not really sure what you mean by multi-threaded, but my guess is that it means to break it down into parts as not to cause lag? If that's the case, no, it doesn't, and I don't think it needs to. It's not a command that will be used a lot, the only thing it does is add something to a small table in a database. I was kinda planning on it only working on one machine, but there is a username and password needed to connect. The only thing I'm worried about is injections, which I don't know a lot about, but I believe this is what they are. Say you type !postnote <message> and the message gets sent to the database. The query would look something like: ("INSERT INTO messages(name, message) VALUES('%s', '%s')", pName.c_str(), M.c_str()) If someone typed !postnote hello the message stored in the database would say "hello". However, if someone was to type something like "!postnote '); DROP renegade;" the literal translation of the query would be: ("INSERT INTO messages(name, message) VALUES('hacker', ''); DROP renegade; ')" Although there would be an error with that code, the basic principal of that is that they could control your database. If the above query didn't have an error, "DROP renegade" would have deleted the entire database, and that obviously wouldn't be good. If I can secure the database to only work with this account on 127.0.0.1 and escape the string (like add a \ before the quotation marks and whatnot) that eliminates two of the main ways they can get in. Does that explain anything?
what u can do is only allow alpha numerical digits to be used in a query which is a handy function we've used to prevent users from posting horrid names into saves which causes a server crash.
Couldn't mysql_real_escape_string work? Then if I run it back out through php, I can just use strip stripslashes I think. Also, would it be more effecient to reconnect every time someone types !postnote or to have an open connection and only send a query when someone types it?