Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Release] Error checking Routine for Mysql [*UPDATED 20/4*]

Newbie Spellweaver
Joined
Apr 6, 2008
Messages
22
Reaction score
0
Re: [Release] Error checking Routine for Mysql [*UPDATED*]

o_0~!
i get this void error..!
can u fix this?


PHP:
void MySQL::insert(char* query){
	mysql_real_query(&maple_db, query, strlen(query));
}
 
Master Summoner
Joined
Apr 2, 2008
Messages
538
Reaction score
0
Re: [Release] Error checking Routine for Mysql [*UPDATED*]

these scripts helped ALOT when it comes to the crashes we been having from time to time ^.^ thanks much.
 
Experienced Elementalist
Joined
Apr 8, 2008
Messages
203
Reaction score
29
Re: [Release] Error checking Routine for Mysql [*UPDATED*]

Thats not the problem, I alraedy caught that b4 you guys >_<

Thats why I stated.. why put BB Codes in a CPP Code lawl.

I and a few people are having the fetching error, look in my Screen Shots

Someone else had that problem yesterday.

It appears some of the code was not carried over on the cut and paste.

There were 2 or 3 lines missing from the code.
 
Junior Spellweaver
Joined
Feb 19, 2006
Messages
112
Reaction score
2
Re: [Release] Error checking Routine for Mysql [*UPDATED*]

Someone else had that problem yesterday.

It appears some of the code was not carried over on the cut and paste.

There were 2 or 3 lines missing from the code.

I'm very sure I copied exactly, and I got Kryptical's error.

Also, I got an access violation error at mysql_free_result(); and ret = mysql_num_rows() lines when the SQL query didn't execute correctly.

Any help?
 
Newbie Spellweaver
Joined
Apr 14, 2008
Messages
61
Reaction score
0
Re: [Release] Error checking Routine for Mysql [*UPDATED*]

Help. I downloaded the file, and changed the x's. When I'm at the login screen I type in my password, and then the server crashes. VC++ opens up MySQLM.cpp file and points a green arrow at
Code:
mrow = mysql_fetch_row(mres);

Here is my MySQLM.cpp script
Code:
#include "MySQLM.h"
#include <sstream>
#include <string>
using namespace std;

MYSQL MySQL::maple_db;

int MySQL::connectToMySQL(){
	if(!mysql_real_connect(&maple_db, "localhost", "root", "", "", 3306, NULL, 0)){
		printf(mysql_error(&maple_db));
		return 0;
	}
	return 1;
}

int MySQL::getInt(char* table, int id, char* value){
	MYSQL_RES *mres;
	MYSQL_ROW mrow;
	char query[255]; 
	int ret = 0; 
	sprintf_s(query, 255, "SELECT %s FROM %s WHERE ID=%d;",value, table, id);
	mysql_real_query(&maple_db, query, strlen(query));
	mres = mysql_store_result(&MySQL::maple_db);
	if (mres == 0 ){
		printf_s("\n\rError in getINT SQL returned no rows (Mysql_error: %s)",mysql_error(&maple_db)); 
		printf_s("SQL Query is : %s",query);
	}
	else {
		mrow = mysql_fetch_row(mres);
		if(mysql_num_fields(mres) > 0){
			string mr = string((char*)mrow[0]);
			istringstream buffer(mr);
			buffer >> ret;
		}
	}
	mysql_free_result(mres);
	return ret;
}

int MySQL::getCharactersIDs(int id, int IDs[3]){
	MYSQL_RES *mres;
	MYSQL_ROW mrow;
	char query[255]; 
    sprintf_s(query, 255, "SELECT ID FROM characters WHERE userid = %d;", id);
	mysql_real_query(&maple_db, query, strlen(query));
	mres = mysql_store_result(&MySQL::maple_db);
	if (mres == 0 ){
		printf_s("\n\rError in getCharactersIDs SQL returned no rows (Mysql_error: %s)",mysql_error(&maple_db)); 
		printf_s("SQL Query is : %s",query);
	}
	else {
		mrow = mysql_fetch_row(mres);
		for(int i=0; i<mysql_num_rows(mres); i++){
			string mr = string((char*)mrow[0]);
			istringstream buffer(mr);
			buffer >> IDs[i];
			mrow = mysql_fetch_row(mres);
		}
	}
	int ret = (int)mysql_num_rows(mres);
	mysql_free_result(mres);
	return ret;
}

int MySQL::isString(char* table, char* whr, char* wht){
	MYSQL_RES *mres;
	MYSQL_ROW mrow;
	char query[255]; 
    sprintf_s(query, 255, "SELECT * FROM %s WHERE %s='%s';",table, whr, wht);
	mysql_real_query(&maple_db, query, strlen(query));
	mres = mysql_store_result(&MySQL::maple_db);
	mrow = mysql_fetch_row(mres);
	if(mrow){
		mysql_free_result(mres);
		return 1;
	}
	else{
		mysql_free_result(mres);
		return 0;
	}
}

void MySQL::getString(char* table, char* whr, char* wht, char* value, char* string){
	MYSQL_RES *mres;
	MYSQL_ROW mrow;
	char query[255]; 
    sprintf_s(query, 255, "SELECT %s FROM %s WHERE %s='%s';",value, table, whr, wht);
	mysql_real_query(&maple_db, query, strlen(query));
	mres = mysql_store_result(&MySQL::maple_db);
	if (mres == 0 ){
		printf_s("\n\rError in getSTRING SQL returned no rows (Mysql_error: %s)",mysql_error(&maple_db)); 
		printf_s("SQL Query is : %s",query);
	}
	else {
		mrow = mysql_fetch_row(mres);
		if(mysql_num_rows(mres) > 0){
			strcpy_s(string, 13, (char*)mrow[0]);
		}
	}
	mysql_free_result(mres);
}
void MySQL::getStringI(char* table, char* whr, int wht, char* value, char* string){
	MYSQL_RES *mres;
	MYSQL_ROW mrow;
	char query[255]; 
    sprintf_s(query, 255, "SELECT %s FROM %s WHERE %s = %d;",value, table, whr, wht);
	mysql_real_query(&maple_db, query, strlen(query));
	mres = mysql_store_result(&MySQL::maple_db);
	if (mres == 0 ){
		printf_s("\n\rError in getStringI SQL returned no rows (Mysql_error: %s)",mysql_error(&maple_db)); 
		printf_s("SQL Query is : %s",query);
	}
	else {
		mrow = mysql_fetch_row(mres);
		if(mysql_num_rows(mres) > 0){
			strcpy_s(string, 13, (char*)mrow[0]);
		}
	}
	mysql_free_result(mres);
}


void MySQL::setInt(char* table, char* wht, int id, int value){
	char query[255]; 
    sprintf_s(query, 255, "UPDATE %s SET %s = %d WHERE ID = %d;", table, wht, value, id);
	mysql_real_query(&maple_db, query, strlen(query));
}

void MySQL::setString(char* table, char* wht, int id, char* value){
	char query[255]; 
    sprintf_s(query, 255, "UPDATE %s SET %s='%s' where ID = %d;", table, wht, value, id);
	mysql_real_query(&maple_db, query, strlen(query));
}

int MySQL::getUserID(char *username){
	MYSQL_RES *mres;
	MYSQL_ROW mrow;
	char query[255]; 
	int ret = 0;
	sprintf_s(query, 255, "SELECT id FROM users WHERE username='%s';",username);
	mysql_real_query(&maple_db, query, strlen(query));
	mres = mysql_store_result(&maple_db);
	if (mres == 0 ){
		printf_s("\n\rError in getUserID SQL returned no rows (Mysql_error: %s)",mysql_error(&maple_db)); 
		printf_s("SQL Query is : %s",query);
	}
	else {
		if(mysql_num_rows(mres) > 0){
			mrow = mysql_fetch_row(mres);
			string mr = string((char*)mrow[0]);
			istringstream buffer(mr);
			buffer >> ret;
		}
	}
	mysql_free_result(mres);
	return ret;
}

int MySQL::setChar(int userid){
	char query[255]; 
    sprintf_s(query, 255, "INSERT INTO characters(userid) VALUES(%d);", userid);
	mysql_real_query(&maple_db, query, strlen(query));
	int IDs[3];
	int num = getCharactersIDs(userid, IDs);
	return IDs[num-1];
}

void MySQL::charInfo(char* wht, int id){
	char query[255]; 
    sprintf_s(query, 255, "UPDATE characters SET %s WHERE ID = %d;", wht, id);
	mysql_real_query(&maple_db, query, strlen(query));
}

void MySQL::deleteRow(char* table, int id){
	char query[255]; 
    sprintf_s(query, 255, "DELETE FROM %s WHERE ID = %d;", table, id);
	mysql_real_query(&maple_db, query, strlen(query));

}

void MySQL::insert(char* query){
	mysql_real_query(&maple_db, query, strlen(query));
}

int MySQL::showEquips(int id, int equips[15][2]){
MYSQL_RES *mres;
MYSQL_ROW mrow;
char query[255];
int ret = 0;
sprintf_s(query, 255, "select equipid, type from equip where charid='%d' and pos<0;", id);
mysql_real_query(&maple_db, query, strlen(query));
mres = mysql_store_result(&MySQL::maple_db);
if (mres == 0 ){
printf_s("\n\rError in showEquips SQL returned no rows (Mysql_error: %s)",mysql_error(&maple_db));
printf_s("SQL Query is : %s",query);
}
mrow = mysql_fetch_row(mres);
for(int i=0; i<mysql_num_rows(mres); i++){
string mr = string((char*)mrow[0]);
istringstream buffer(mr);
buffer >> equips[i][0];
string mr2 = string((char*)mrow[1]);
istringstream buffer2(mr2);
buffer2 >> equips[i][1];
mrow = mysql_fetch_row(mres);
}
return (int)mysql_num_rows(mres);
mysql_free_result(mres);
}
int MySQL::showEquipsIn(int id, int equips[115][21]){
	MYSQL_RES *mres;
	MYSQL_ROW mrow;
	char query[255]; 
    sprintf_s(query, 255, "SELECT * FROM equip WHERE charid = %d;", id);
	mysql_real_query(&maple_db, query, strlen(query));
	mres = mysql_store_result(&MySQL::maple_db);
	if (mres == 0 ){
		printf_s("\n\rError in getEquipsIn SQL returned no rows (Mysql_error: %s)",mysql_error(&maple_db)); 
		printf_s("SQL Query is : %s",query);
	}
	else {
		mrow = mysql_fetch_row(mres);
		for(int i=0; i<mysql_num_rows(mres); i++){
			for(int j=0; j<21; j++){
				string mr = string((char*)mrow[j]);
				istringstream buffer(mr);
				buffer >> equips[i][j];
			}
			mrow = mysql_fetch_row(mres);
		}
	}
	int ret = (int)mysql_num_rows(mres);
	mysql_free_result(mres);
	return ret;
}

int MySQL::getItems(int id, int equips[400][4]){
	MYSQL_RES *mres;
	MYSQL_ROW mrow;
	char query[255]; 
    sprintf_s(query, 255, "SELECT * FROM items WHERE charid = %d;", id);
	mysql_real_query(&maple_db, query, strlen(query));
	mres = mysql_store_result(&MySQL::maple_db);
	if (mres == 0 ){
		printf_s("\n\rError in getItems SQL returned no rows (Mysql_error: %s)",mysql_error(&maple_db)); 
		printf_s("SQL Query is : %s",query);
	}
	else {
		mrow = mysql_fetch_row(mres);
		//int ret = 0;
		for(int i=0; i<mysql_num_rows(mres); i++){
			for(int j=0; j<5; j++){
				string mr = string((char*)mrow[j]);
				istringstream buffer(mr);
				if(j>1)
					buffer >> equips[i][j-1];
				else if(j!=1)
					buffer >> equips[i][0];
			}
			mrow = mysql_fetch_row(mres);
		}
	}
	int ret = (int)mysql_num_rows(mres);
	mysql_free_result(mres);
	return ret;
}
int MySQL::getSkills(int id, int skills[200][2]){
	MYSQL_RES *mres;
	MYSQL_ROW mrow;
	char query[255]; 
    sprintf_s(query, 255, "SELECT * FROM skills WHERE charid = %d;", id);
	mysql_real_query(&maple_db, query, strlen(query));
	mres = mysql_store_result(&MySQL::maple_db);
	if (mres == 0 ){
		printf_s("\n\rError in getSkills SQL returned no rows (Mysql_error: %s)",mysql_error(&maple_db)); 
		printf_s("SQL Query is : %s",query);
	}
	else {
		mrow = mysql_fetch_row(mres);
		//int ret = 0;
		for(int i=0; i<mysql_num_rows(mres); i++){
			for(int j=1; j<3; j++){
				string mr = string((char*)mrow[j]);
				istringstream buffer(mr);
				buffer >> skills[i][j-1];
			}
			mrow = mysql_fetch_row(mres);
		}
	}
	int ret = (int)mysql_num_rows(mres);
	mysql_free_result(mres);
	return ret;
}
void MySQL::getKeys(int id, int keys[90]){
	MYSQL_RES *mres;
	MYSQL_ROW mrow;
	char query[255]; 
	int ret = 0;
    sprintf_s(query, 255, "SELECT * FROM keymap WHERE charid = %d;", id);
	mysql_real_query(&maple_db, query, strlen(query));
	mres = mysql_store_result(&MySQL::maple_db);
	if (mres == 0 ){
		printf_s("\n\rError in getKeys SQL returned no rows (Mysql_error: %s)",mysql_error(&maple_db)); 
		printf_s("SQL Query is : %s",query);
	}
	else {
		mrow = mysql_fetch_row(mres);
		for(int i=0; i<90; i++){
			string mr = string((char*)mrow[i+1]);
			istringstream buffer(mr);
			buffer >> keys[i];
		}
	}
	mysql_free_result(mres);
}
 
Experienced Elementalist
Joined
Apr 8, 2008
Messages
203
Reaction score
29
Re: [Release] Error checking Routine for Mysql [*UPDATED*]

I am looking into the problem and will post an updated version.
 
Newbie Spellweaver
Joined
Mar 24, 2006
Messages
93
Reaction score
0
Re: [Release] Error checking Routine for Mysql [*UPDATED*]

Wow...
Thats some nice butt release!
Thanks alot man!! x3
 
Newbie Spellweaver
Joined
Apr 6, 2008
Messages
22
Reaction score
0
my SQLget error
everytime try anyaccount in the game..
the server will crash... why??
Dichotome - [Release] Error checking Routine for Mysql [*UPDATED 20/4*] - RaGEZONE Forums
 
Experienced Elementalist
Joined
Apr 8, 2008
Messages
203
Reaction score
29
my SQLget error
everytime try anyaccount in the game..
the server will crash... why??
Dichotome - [Release] Error checking Routine for Mysql [*UPDATED 20/4*] - RaGEZONE Forums


What error do you get ? Just saying the server crashes makes it impossible to help you.

Are there any messages printed out on the application screen ?
 
Initiate Mage
Joined
Apr 21, 2008
Messages
1
Reaction score
0
I get this message in a window;
Code:
Unhandled exception at 0x00434fb3 in MapleStoryServer.exe: 0xC0000005: Access violation reading location 0x00000000.

this is parts from the debug output;
Code:
...
'MapleStoryServer.exe': Unloaded 'C:\WINDOWS\system32\shimeng.dll'
...
First-chance exception at 0x00434fb3 in MapleStoryServer.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x00434fb3 in MapleStoryServer.exe: 0xC0000005: Access violation reading location 0x00000000.
First-chance exception at 0x00434fb3 in MapleStoryServer.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x00434fb3 in MapleStoryServer.exe: 0xC0000005: Access violation reading location 0x00000000.

and this is from the "MySQLM.cpp"; (shown in this picture: (only the ".cpp" is the same(I got the XP version of VC++)))
Code:
			string mr = string((char*)mrow[0]);

I'll keep trying to fix it, but some help would be fine.
 
Back
Top