从Android应用程序中,该应用程序将查询php脚本并在MySQL数据库中查找新消息
为了防止毫无意义地使用数据,我实现了一个"if"语句,以检查数据库中的消息是否为空。如果消息为空,则不应回复Android应用程序。
我的问题&php代码:
if语句未被检测到,并且一直返回数据:
<?php
if($_REQUEST['pass'] == null){
die("You Are Not Logged In");
}
$q=mysql_query("SELECT * FROM $tbl_name WHERE pass='".$_REQUEST['pass']."'");
while($e=mysql_fetch_assoc($q)){
$result1=$e['message'];
////Here the Message = 'No Message' but the Scrpit Continue ...
if($result1 == 'No Message'){
exit(0);
die("No Message");
}
$output[]=$e;
print(json_encode($output));
}
if($_REQUEST['status'] != null){
$sq2="UPDATE $tbl_name SET status='".$_REQUEST['status']."' WHERE pass='".$_REQUEST['pass']."'";
$result=mysql_query($sq2);
}
mysql_close();
?>
查询不返回任何内容,mysql_fetch_assoc
立即返回false,跳过整个块。
谢谢大家,使用解决了问题
if($result1 == ' '){
exit(0);
die("No Message");}
Logcat say:message=null&分析Json数据时出错,关于SQL注入,请注意。。。