When I run the source code below in Dev C++, I get the following error:
How do I resolve this error message?
2711 C:\Users\patch\Documents\main.cpp [Error] cannot convert 'char**(MYSQL_RES*) {aka char**(st_mysql_res*)}' to 'MYSQL_ROW {aka char**}' in assignment
28 C:\Users\patch\Documents\Makefile.win recipe for target'main.o'failed
Enter your code here
#include<stdio.h>
# include <stdlib.h>
# include <string.h>
# include <C:\Program Files\MySQL\MySQL Server 5.7\include/mysql.h>
int main()
// intres(const char*s)
{
MYSQL*m;
MYSQL_RES*r;
MYSQL_ROWw;
MYSQL_STMT*s;
MYSQL_BIND par[2];
MYSQL_BINDres[2];
charsd[4][60];
unsigned long sdl[4];
my_boolnl[4];
char sql1[] = "SELECT user, host FROM mysql.user WHERE host LIKE '%localhost%'";
charsql2[] = "SELECT user, host FROM mysql.user WHERE host LIKE?";
mysql_real_connect(m, "localhost", "root", "", "test", 0, NULL, 0);
puts("Regular Execution");
mysql_real_query(m,sql1,strlen(sql1));
r=mysql_store_result(m);
while(w=mysql_fetch_row)
{
printf("%s@%s\n", w[0], w[1]);
}
puts("Prepared Statement");
mysql_stmt_prepare(s,sql2,strlen(sql2));
// parameter
par[0].buffer_type = MYSQL_TYPE_STRING;
par[0].buffer=sd[0];
par[0].is_null = 0;
par[0].length=&sdl[0];
mysql_stmt_bind_param(s,par);
strncpy(sd[0], "%localhost%", 60);
sdl[0] = strlen(sd[0]);
mysql_stmt_execute(s);
res[0].buffer_type = MYSQL_TYPE_STRING;
res[0].buffer=sd[1];
res[0].buffer_length = 60;
res[0].is_null=&nl[1];
res[0].length=&sdl[1];
res[1].buffer_type = MYSQL_TYPE_STRING;
res[1].buffer=sd[2];
res[1].buffer_length = 60;
res[1].is_null=&nl[2];
res[1].length=&sdl[2];
mysql_stmt_bind_result(s,res);
while(w=mysql_fetch_row(r))
{
printf("%s@%s\n", sd[1], sd[2]);
}
mysql_stmt_free_result(s);
mysql_stmt_close(s);
mysql_close(m);
}
while(w=mysql_fetch_row)
The part of is
while(w=mysql_fetch_row(r))
I think it is.
© 2024 OneMinuteCode. All rights reserved.