• Welcome to Valhalla Legends Archive.
 

Need Help With Mysql and C++[Resolved]

Started by Final, April 16, 2006, 07:55 PM

Previous topic - Next topic

Final

Ok well Its been a couple of hours and I cant seem to find any good tutorials on using mysql.h By itself I tried all the wrappers they always have a damn error so I dont deal with them. Ive been trying to gather data from mysql server with just mysql.h and I cant seem to output data.

this is what i have so far.

MYSQL* mysql = mysql_init(NULL);
           MYSQL_RES* _result;
           MYSQL_ROW _curr_row;
           MYSQL* _handle; 
           int index=0;
           char sx[MAX_PATH];
           mysql_real_connect(mysql,"127.0.0.1","root","blah","Main",PORT,0,1);
           mysql_query(mysql,"SELECT * FROM members WHERE username=`unkownname`");
           _curr_row = mysql_fetch_row(_result);
           char* data = _curr_row[1];

what should i do next to do this right cuz it always crashes when it gets here

char* data = _curr_row[1];

??
I really really need help on this.

warz

What's the error? And does mysql_real_connect open the table and database and everything?

Final

#2
sorry everyone after taking 6 hours of my life I figured it out blindy I made contact got my first variable back and never been happier if anyone need source on how to do it ask me.

//Got another problem with mysql and c++ though//
I have been making a server in c++ for the past few months that wy I needed mysql.
Now that i have it working I have the data outputed like this.
Row[0]= ID
Row[1]= Username
Row[2]= Password
And i have a packet buffer reading authentication from client side.
So i Parse like so
Switch(buffer[1]){
//All buffer code goes here//
}
But Im having a problem I get my packet information like so.
char* username=buffer+4;
char* password=buffer+sizeof(username)+5;
what Im having problems is, When i try doing an if() on it to check if passwords match like so.
if(password==Row[2]){
//I Add A success//
}else{
//I Denied//
}
But for somereason Everything is correct password= Blah and Row[2]= Blah
But It dont Accept it for $hit could someone tell me wy.

warz

well, it shouldn't let you compile like that. you'll need to look up the functions strncmp or strcmp on msdn and use either one

Kp

Quote from: warz on April 17, 2006, 03:25 AM
well, it shouldn't let you compile like that. you'll need to look up the functions strncmp or strcmp on msdn and use either one

Why not?  His grammar is atrocious, but his code looks syntactically valid.  It's wrong for what he wants it do to, but it's syntactically OK.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Final

#5
Well Thanks for Ciritsm and flatter my code. Hmm So now I see I have something wrong by what you guys say so what should id do to do right cuz what i did Did get the values of my mysql database but couldnt compare.
--Sorry for last part of that Let me try out that function;
Update Sorry To bother but could i get an example from you guys simple one because the freaking stuff websites are giving me are farely wierd if it is less than equal to 0 or less than wtf ? im having trouble.

Kp

For a self-proclaimed decent programmer, you don't seem very good.  Your spelling shows what I hope is merely a lack of care, and your punctuation's no better.  A decent programmer would've tried stepping through in a debugger to analyze what's failing.  I'd offer you some help out of pity, but I don't see the point wading through your post to try to find the question, if one is even articulated well enough to be answered.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Final

Sorry I was reading up on wrong function it was second strcmp sorry about that kp

TheMinistered

#8
Quote
For a self-proclaimed decent programmer, you don't seem very good.  Your spelling shows what I hope is merely a lack of care, and your punctuation's no better.  A decent programmer would've tried stepping through in a debugger to analyze what's failing.  I'd offer you some help out of pity, but I don't see the point wading through your post to try to find the question, if one is even articulated well enough to be answered.

I love the enthusiasm there... I mean really... I gotta lol for a min... OK Like do you really think that helps guy?  I mean guy probably is fairly new and maybe a bit cocky... but why not send him down the road of wisdom instead of insulting him kp, you yellow belly turd ^^. 

EDIT:  You ever consider maybe he is using the english version of the IDE and perhaps this guy is hispanic, asian (invasion), russian, german, deutch, etc??? Maybe he is a beginner non-caucasian programmer-- perhaps his skills in assembly are more elite than you, he would be a great honor to have here at VALHALLA LEGENDS

Final

#9
well thanks for compliment and im Hispanic but I use english more than spanish I know how to speak english very well its just my spelling sucks sorry if that bothers anyone here I always get some comment on that. Like Stealthbot everyone got mad at my spelling and didnt pay attention to my problem I felt really down but yet again someone goes and does it again stealthbot dosent do it anymore but its like , were ever i go ill always be insulted.