• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

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

Experienced Elementalist
Joined
Apr 8, 2008
Messages
203
Reaction score
29
Re: [Release] Error checking Routine for Mysql

One error:
Code:
c:\documents and settings\compaq_owner\desktop\titanmsver007\maplestoryserver\maplestoryserver\mysqlm.cpp(170) : error C2059: syntax error : '='


What does the line say that has the error - chances are my line 170 is nothing like yours due to extra code in mine..
 
Last edited:
Master Summoner
Joined
Apr 2, 2008
Messages
538
Reaction score
0
Re: [Release] Error checking Routine for Mysql

Yeh um im pretty confused >.<
 
Newbie Spellweaver
Joined
Apr 15, 2008
Messages
16
Reaction score
0
Re: [Release] Error checking Routine for Mysql

Which one to use :3
 
Newbie Spellweaver
Joined
Apr 7, 2008
Messages
72
Reaction score
0
Re: [Release] Error checking Routine for Mysql

i got it compiled no errors.

my rev007 script

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[0];
string mr2 = string((char*)mrow[1]);
istringstream buffer2(mr2);
buffer2 >> equips[1];
mrow = mysql_fetch_row(mres);
}
return (int)mysql_num_rows(mres);
mysql_free_result(mres);
}
 
Experienced Elementalist
Joined
Apr 8, 2008
Messages
203
Reaction score
29
Re: [Release] Error checking Routine for Mysql

Yeh um im pretty confused >.<


If you copy and paste your line 170 from your mysql.cpp file I can try and find where the error is coming from.
 
Junior Spellweaver
Joined
Apr 4, 2008
Messages
109
Reaction score
0
Re: [Release] Error checking Routine for Mysql

Wow, Somehow this fixed some server crashes errors TY!
 
Experienced Elementalist
Joined
Apr 8, 2008
Messages
203
Reaction score
29
Re: [Release] Error checking Routine for Mysql

i got it compiled no errors.

my rev007 script

int MySQL::showEquips(int id, int equips[15][2]){
MYSQL_RES *mres;
MYSQL_ROW mrow;
char query[255];

*** lines omitted to make post shorter ***

return (int)mysql_num_rows(mres);
mysql_free_result(mres);
}

The only problem will be, it never executes the line marked in red, as the 'return' on the previous line exits the routine at that point.
 
Last edited:
Master Summoner
Joined
Apr 2, 2008
Messages
538
Reaction score
0
Re: [Release] Error checking Routine for Mysql

K hold on for a minute.
 
Newbie Spellweaver
Joined
Apr 7, 2008
Messages
72
Reaction score
0
Re: [Release] Error checking Routine for Mysql

ya bro this saves alot of crashing i barely get any anymore good stuff
 
Master Summoner
Joined
Apr 2, 2008
Messages
538
Reaction score
0
Re: [Release] Error checking Routine for Mysql

got it to work :x....i changed

ret to return at first xD..i thought it was wrong.
 
Newbie Spellweaver
Joined
Apr 15, 2008
Messages
16
Reaction score
0
Re: [Release] Error checking Routine for Mysql

which one should i follow, i copied the one the DBZ dude posted
 
Experienced Elementalist
Joined
Apr 8, 2008
Messages
203
Reaction score
29
Re: [Release] Error checking Routine for Mysql

The very first post contains the correct one.
 
Newbie Spellweaver
Joined
Apr 7, 2008
Messages
72
Reaction score
0
Re: [Release] Error checking Routine for Mysql

if your running rev007 and u c+p it, it wont work, u only need to add the important stuff. IF you copy and paste mine it wont work cuz its out of correct formatting but just make sure you have those lines in the correct part of the script.
 
Newbie Spellweaver
Joined
Apr 15, 2008
Messages
16
Reaction score
0
Re: [Release] Error checking Routine for Mysql

Ok I understand now
 
Job Accomplished!
Joined
Jul 7, 2006
Messages
294
Reaction score
0
Re: [Release] Error checking Routine for Mysql

Works 100% no compilation errors. :grin:

To those getting errors.

Open MySQLM.cpp and find int MySQL::showEquips(int id, int equips[15][2]){

Remove the entire function and replace it with the code below.

Code:
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);
	//int ret = 0;
	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);
    return ret;
}

THIS IS FOR REV 7
 
Experienced Elementalist
Joined
Apr 8, 2008
Messages
203
Reaction score
29
Re: [Release] Error checking Routine for Mysql

Here are all the routines that code can go into
(with no highlights so you can cut and paste the ones you want).

***** moved the code to first posting *****
 
Last edited:
Newbie Spellweaver
Joined
Feb 17, 2008
Messages
28
Reaction score
0
Re: [Release] Error checking Routine for Mysql

Here are all the routines that code can go into
(with no highlights so you can cut and paste the ones you want).

Code:
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;
}
Code:
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);
        int ret = 0;
        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;
}
Code:
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);
}
Code:
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);
}
Code:
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;
}
Code:
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);
    }
    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 >> equips[i][0];
            string mr2 = string((char*)mrow[1]);
            istringstream buffer2(mr2);
            buffer2 >> equips[i][1];
            mrow = mysql_fetch_row(mres);
        }
    }
    ret = (int)mysql_num_rows(mres);
    mysql_free_result(mres);
    return ret;
}
Code:
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;
}
Code:
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;
}
Code:
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;
}
Code:
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);
}



um what do all these do? like a routine error check i get it, but what exactly?
 
Elite Diviner
Joined
Feb 28, 2007
Messages
446
Reaction score
4
Re: [Release] Error checking Routine for Mysql [*UPDATED*]

I'm getting this ;o
Dichotome - [Release] Error checking Routine for Mysql [*UPDATED 20/4*] - RaGEZONE Forums
 
Experienced Elementalist
Joined
Apr 8, 2008
Messages
203
Reaction score
29
Re: [Release] Error checking Routine for Mysql [*UPDATED*]

They just check that the database actually returns requested data.
If you try and use the data when it has not returned any, you get access violation errors as the pointers are not set and these crash your server.
 
Back
Top