Sign in to follow this  
ortsa

[SOLVED]Could use some help with mysql++ if anyones used it before

Recommended Posts

ortsa    122
I have this function
bool CheckLoginDetails(CPacket *loginPacket, ENetPeer *TPeer)
{
	string username(loginPacket->ReadString());
	string password(loginPacket->ReadString());

	string queryCommand("SELECT * FROM login WHERE username = ");
	queryCommand.append(username);
	queryCommand.append(" AND password = ");
	queryCommand.append(password);

	if (mysqlpp::Query theQuery = conn->query(queryCommand.c_str()))
	{
		if (mysqlpp::StoreQueryResult theResult = theQuery.store())
		{
			if (theResult.num_rows() == 0)
			{
				return false;
			}
			else
			{
				return true;
			}
		}		
	}

	return false;
}
EDIT: Iv refined my code a little, the error happens when i call theQuery.store() and i get some random access violation in xstring it says mysqlpp::BadQuery, can anyone see if my sql is correct? Also c++,vc2005. Well, i dont know how but iv fixed it woohooo [Edited by - ortsa on August 12, 2008 6:23:41 AM]

Share this post


Link to post
Share on other sites
UncleRemus    313
Quote:
Original post by ortsa
I thought that too but in the documentation it says quotes arent needed for strings without spaces


But if someone enters an SQL statement in username, you could get in trouble.

Uncle

EDIT : but this is probably totally unrelated to the problem you have

Share this post


Link to post
Share on other sites
ortsa    122
Quote:
Original post by UncleRemus
Quote:
Original post by ortsa
I thought that too but in the documentation it says quotes arent needed for strings without spaces


But if someone enters an SQL statement in username, you could get in trouble.

Uncle

EDIT : but this is probably totally unrelated to the problem you have


Yes but thanks for bringing that up, should save me some trouble

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this