The reason this is not working is that MYSQL_ROW row and an integer of 1 or 0 are not of the same data type. How would i make them the same data type?mysql_query(conn,"SELECT COUNT(*) FROM tblURL WHERE IP = ''192.168.1.399'' AND Status = ''Active''");
my_ulonglong i = 0;
res_set = mysql_store_result(conn);
my_ulonglong numrows = mysql_num_rows(res_set);
{
row = mysql_fetch_row(res_set);
if (row[i] = 1) //THIS IS THE ISSUE??????/
printf("YES: %s\n",row[i]);
else
printf("NO: %s\n",row[i]);
}
mysql_free_result(res_set);
mysql_close(conn);
system("PAUSE");
/*End Works*/
}
解决方案Take a look at the documentation here[^], which explains the data types returned by MySQL functions. mysql_fetch_row() returns a database row not an integral value.
first off...
in an if statement:
if(x = 1) //
if(x == 1) //
second (assuming the rest of your code is kosher, i''m pretending it is)...
you have to look up what MYSQL_ROW is typedef''ed from, if its an int, then a comparator should work, but if you need to cast it, you need to do an explicit cast (usually if you have to do this you should know what you''re doing as far as data types, could lead to crashes, bugs, or loss of data):
MYSQL_ROW row;
int x= (int) row; //
//In a statement
if(x == row) //
if(x == (int)row) //
I''d help you more with the SQL portion of it but its been years since I last did SQL.
*****Update:*****
int value; //
int row[10]; //
if(row == 1) //
if(row[2] == 1) //