当前位置: 技术问答>linux和unix
mysql编译问题
来源: 互联网 发布时间:2015-12-11
本文导语: 源码: #include #include int test(); int main() { test(); return 0; } int test() { MYSQL mysql; // need a instance to init MYSQL_RES *res; MYSQL_ROW row; char *query; int t; // connect the database mysql_init(&my...
源码:
#include
#include
int test();
int main()
{
test();
return 0;
}
int test()
{
MYSQL mysql; // need a instance to init
MYSQL_RES *res;
MYSQL_ROW row;
char *query;
int t;
// connect the database
mysql_init(&mysql);
if (!mysql_real_connect(&mysql,"192.168.20.229", "root", "heslo", "sipdb",0,NULL,0))
{
printf( "Error connecting to database: %sn",mysql_error(&mysql));
}
else printf("Connected...n");
// get the result from the executing select query
query = "select * from presence";
t = mysql_real_query(&mysql,query,(unsigned int) strlen(query));
if (t)
{
printf("Error making query: %sn",
mysql_error(&mysql));
}
else printf("[%s] made...n", query);
res = mysql_store_result(&mysql);
while(row = mysql_fetch_row(res))
{
for(t=0;t
#include
#include
int test();
int main()
{
test();
return 0;
}
int test()
{
MYSQL mysql; // need a instance to init
MYSQL_RES *res;
MYSQL_ROW row;
char *query;
int t;
// connect the database
mysql_init(&mysql);
if (!mysql_real_connect(&mysql,"192.168.20.229", "root", "heslo", "sipdb",0,NULL,0))
{
printf( "Error connecting to database: %sn",mysql_error(&mysql));
}
else printf("Connected...n");
// get the result from the executing select query
query = "select * from presence";
t = mysql_real_query(&mysql,query,(unsigned int) strlen(query));
if (t)
{
printf("Error making query: %sn",
mysql_error(&mysql));
}
else printf("[%s] made...n", query);
res = mysql_store_result(&mysql);
while(row = mysql_fetch_row(res))
{
for(t=0;t