int main(int argc, char *argv[])
{
char string1[1600], string2[1600], query[1600], query1[1600], mobileno[50];
int i, j, len;
FILE *fp2;
mysql_init(&conn);
/* Connect to database */
if (!mysql_real_connect(&conn, host, user, password, database, 0, NULL, 0)) {
fprintf(stderr, "%s\n", mysql_error(&conn));
exit(0);
}
/* send SQL query */
bzero(query1, sizeof(query1));
sprintf(query1, "select a.CreateDate, a.MobileNumber, b.BillName, b.CorrName, b.ICNew, b.ICOld, b.Passport,"
"b.Addr, b.Addr2, b.Addr3, b.Addr4, b.Postcode, b.CountryCode from Register as a, Profile as b"
" where a.MasterNumber = b.Number and a.Status=0");
printf ("%s\n",query1);
if (mysql_query(&conn, query1))
{
fprintf(stderr, "%s\n", mysql_error(&conn));
exit(0);
}
res = mysql_use_result(&conn);
/* output fields 0, 1 and 2 of each row */
while ((row = mysql_fetch_row(res)) != NULL)
{
if (i==11)
{
timebuffer();
i=1;
bzero(string1, sizeof(string1));
}
else
{
sprintf(string1,"%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s",
row[0], row[1], row[14], row[15], row[16], row[17], row[18], row[4],
row[5], row[6], row[7], row[12], row[13]);
sprintf(mobileno,"%s", row[1]);
printf ("%s\n",string1);
printf ("Test: %s\n",mobileno);
writeLogFile(string1, mobileno);
i++;
}
/* Release memory used to store results and close connection */
mysql_free_result(res);
mysql_close(&conn);
return 0;
}
}