I'm trying to write a function to retrieve a particular field from a mysql database. I'm getting a compiler warning "assignment makes pointer from integer without a cast"
I'm not sure if I'm using the right logic to go about this but I thought I'd use a similar format which was suggested here last week ...anyway the code looks like this:
#include <stdio.h>
#include <stdlib.h>
#include "mysql.h"
int chk_sender(char *Uname, char *Udomain)
{
MYSQL_RES *result;
MYSQL *connection, mysql;
char sql_str[1024];
mysql_init(&mysql);
connection = mysql_real_connect(&mysql, "localhost","root", "", "senders", 0, NULL, 0);
if (connection == NULL)
{
printf("mysql_error(&mysql)\n");
return 1;
}
sprintf(sql_str, "SELECT ap_senders FROM sendtable1WHERE pw_name='%s' and pw_domain='%s';", Uname, Udomain);
result = mysql_query(connection, sql_str);
if (result != 0)
{
printf(mysql_error(connection));
return 1;
}
//now to call mysql store result to store the value in memory
result = mysql_store_result(connection);
printf("Rows: %d\n", mysql_num_rows(result));
//now to free the result set
mysql_free_result(result);
//and then to close the connection
mysql_close(connection);
printf("Done\n");
}
Any hints on how to correct the compiler warning?
Thanks,
Regis