• Advertisement
Sign in to follow this  

Problem getting data from mysql (rows)

This topic is 4982 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, im having a problem with this code (descriped below)
int checklogin(char * username, char * password)
{
	mysql_query(pConn,"SELECT * FROM account");
	result = mysql_use_result(pConn);
	mysql_free_result(result);

	char* query = new char[100];
	sprintf(query,"SELECT * FROM account WHERE username=%s && password=%s", username, password);
	
	if(!mysql_query(pConn,query))
	{
		// error doing the query
		Log2File(TRUE, "(MySQL) ERROR : %s\n", mysql_error(pConn));
		return 0;
	}
	else
	{
		result = mysql_use_result(pConn);
		// fetch all the rows from the query.
		while ((row = mysql_fetch_row(result))) 
		{ 
		}

		// if there is no rows returned.
		if(mysql_num_rows(result) == 0)
		{
			mysql_free_result(result);
			return 0;
		}

		// the username and password match.
		else
		{
			mysql_free_result(result);
			return 1;
		}
	}
	return 0;
}

it is supposed to check the category account for a match with the descriped username/password, but it doesnt, it crashes my application and i cant seem to find the error. i do however belive it got something to do with fecthing of the row... btw, im making this in visual c++ 6 (sp5) as a win32 app anyone got an idea where this error is happening ?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement