#include "SQL.h"
const char * pQuery(const char * query,...)
{
va_list argptr;
va_start( argptr, query);
char buf[4096] = "";
sprintf(buf,"");
int ret = vsprintf(buf + strlen(buf), query, argptr);
strcpy(buf + strlen(buf), "");
va_end( argptr );
return buf;
}
MYSQL * mysql;
int main()
{
//loading the config file
IniFile cf("Config.ini");
//mysql connection
Log("Attempting MySQL Connection");
mysql = mysql_init(mysql);
MYSQL_RES *result;
MYSQL_ROW row;
int query_state;
string host= cf.Value("Database","DBServer");
string user=cf.Value("Database","LoginName");
string pass=cf.Value("Database","Password");
string db=cf.Value("Database","DBName");
if (!mysql_real_connect(mysql,host.c_str(),user.c_str(),pass.c_str(),db.c_str(),NULL,NULL,NULL))
{
Error(mysql_error(mysql));
Log("(!Error!) MySQL connection rejected!\n");
mysql_close(mysql);
getch();
return 0;
}
char name[4096];
char password[4096];
cin >> name;
cin >> password;
//const char query= pQuery("sleect * from account where name=%s and password=%s",name,password);
query_state = mysql_query(mysql, pQuery("select * from account where `name`='%s' and `password`='%s'",name,password));
if (query_state !=0) {
Log("Query !!Error!!");
Error(mysql_error(mysql));
getch();
return 1;
}
result = mysql_store_result(mysql);
while ( ( row = mysql_fetch_row(result)) != NULL ) {
if((name==row[1]) && (password==row[2]))
{
Log("Loged in");
}
else
{
Log("wrong info");
}
}
getch();
}
in the both cases it's say wrong info while it's right not worng also i have this err
4 IntelliSense: a trailing return type requires the 'auto' type specifier d:\c++\upgaccserver\mysql\include\mysql.h 186
anyclue :(