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;
}
Problem getting data from mysql (rows)
Hi all, im having a problem with this code (descriped below)
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 ?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement