#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <mysql/mysql.h>
int main()
{
MYSQL mysql;
MYSQL_RES *result;
MYSQL_ROW row;
unsigned int fields_num, i;
char *query;
query = (char *)malloc(1024);
memset(query, '', 1024);
strcpy(query,"select * from MMO");
if( !mysql_init(&mysql) )
{
printf("Mysql init Error!!!
");
exit(1);
}
if( !mysql_real_connect(&mysql, "localhost", "next72", "something", "MMO", 0, NULL, 0) )
{
printf("Mysql server connect Error!!!
");
exit(1);
}
if( mysql_query(&mysql, query) == 0 )
{
if( !(result = mysql_store_result(&mysql)) )
{
fields_num = mysql_num_fields(result);
for( i = 0; i < fields_num; i++ )
printf("%s ", row);
mysql_free_result(result);
}
else
printf("result NO!!!
");
}
else
printf("query send error!!!
");
printf("Error : %s", mysql_error(&mysql));
printf("
");
mysql_close(&mysql);
}
무엇이 틀렸는지 감이 안오네여..
이걸 재가 처음 한거라서요~~
그럼 답변 감사드립니다..
|