In my app I am able to connect to a MySQL db and perform a query but I am having problems parsing the returned data. Here's my code:
I keep getting an warning that num_fields makes a pointer from integer without a cast, but wouldn't mysql_num_fields() return an integer? And let me take this moment to whine about the lack of a mysql_fetch_array or mysql_fetch_assoc in the C API...
Rereading my question should I be assigning results to something other than an int?
Code:
- (IBAction)dbConnect:(id)sender {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
MYSQL conn;
mysql_init(&conn);
if (!mysql_real_connect(&conn, "10.1.1.99", "*******", "******", "oldphotoarchive", 0, NULL, 0)) {
NSLog(@"%@", [NSString stringWithUTF8String:mysql_error(&conn)]);
} else {
int results = mysql_query(&conn, "SELECT * FROM photorecord");
if (results == 0) {
MYSQL_ROW row;
unsigned int num_fields;
unsigned int i;
num_fields = mysql_num_fields(results);
NSLog(@"%i", num_fields);
}
}
[pool release];
}
I keep getting an warning that num_fields makes a pointer from integer without a cast, but wouldn't mysql_num_fields() return an integer? And let me take this moment to whine about the lack of a mysql_fetch_array or mysql_fetch_assoc in the C API...
Rereading my question should I be assigning results to something other than an int?