我想按照下面的调用从 mysql 调用中获取一个整数,然后比较该值是 0 还是 1,我似乎对 NSSTRING 和 NURL 有问题...请帮助
当我将 mysql 设置为 value = 1 时,我仍然没有得到 NSLOG 的输出
NSURL *database_flag_query;
NSString *database_flag;
database_flag_query = [NSURL URLWithString: [NSString stringWithFormat: @"http://192.168.0.20/iqkradio_stream_ip.php"]];
database_flag = [NSString stringWithContentsOfURL:database_flag_query encoding:NSASCIIStringEncoding error:&error];
if([database_flag isEqualToString: @"1"])
{NSLog(@"flag = 1");}
新代码
database_flag_query = [NSURL URLWithString:@"http://192.168.0.20/iqkradio_stream_ip.php"];
database_flag = [NSString stringWithContentsOfURL:database_flag_query encoding:NSASCIIStringEncoding error:&error];
NSLog(database_flag);
if([database_flag isEqualToString: @"1"])
{NSLog(@"flag is set");}
这也是我的mysql查询
mysql_select_db("qkradio", $con);
$result = mysql_query("select flag from iqkradio" );
while($row = mysql_fetch_array($result)) {
echo $row['flag'];