php不工作显示空白页面

时间:2015-05-18 02:20:05

标签: php mysql arrays

我正在使用远程访问数据库开发Android应用程序,因此我使用PHP连接mySQL数据库。但是,我的PHP代码显示空白页面,我找不到原因,请任何帮助将不胜感激..

<?php


// include db connect class
require_once __DIR__ . '/db_connect.php';
$response = array();
$groupname = array();
$response["Groups"]=array();
//if (isset($_POST['FID5'])){

//$FID = $_POST['FID5'] ;


$FID = '6';// here im just for testing it
  if($FID == '6'){


$db = new DB_CONNECT();
mysql_query("SET NAMES utf8");
// get all classrooms from classroom clinic table
$result1 = mysql_query("SELECT * FROM `facultymanagegroup` WHERE FID =         '$FID'");
if (mysql_num_rows($result1)>0) {
while ($row1 = mysql_fetch_array($result1)) {
$groupid = $row1['GroupID'];

$result = mysql_query("SELECT * FROM `group` where GroupType= 'Course Group'      AND GroupID = '$groupid' ");
if (mysql_num_rows($result)>0) {
while ($row2 = mysql_fetch_array($result)) {
   $Group = array();
   $Group["GroupID"] = $row2["GroupID"];
   $Group["GroupName"] = $row2["GroupName"];
    $Group["GroupType"] = $row2["GroupType"];

     $groupn = $row2["GroupID"];
     array_push($groupname, $groupn);

    array_push($response["Groups"], $Group);}}
    }}


$result3 = mysql_query("SELECT * FROM `group` where GroupType= 'Course  Group' AND fID = '$FID'");
if($result3 === FALSE) { 
die(mysql_error()); // TODO: better error handling
}

// check for empty result
if (mysql_num_rows($result3)>0) {
// looping through all results
// classroom node
while ($row4 = mysql_fetch_array($result3)) {
    // temp user array
 for ($i = 0; $i < count($groupname); ++$i) {   

    $Group = array();
    $Group["GroupID"] = $row4["GroupID"];
    $Group["GroupName"] = $row4["GroupName"];
    $Group["GroupType"] = $row4["GroupType"];
    if($groupname[$i] == $row4["GroupID"]; ){
    $ok = 0 ;
    Break;
   }
   else{
   $ok = 1 ;
}}
if($ok == 1){
      array_push($response["Groups"], $Group);

}   
}
// success
$response['success'] = 1;

// echoing JSON response
} else {
// no classrooms found
$response['success'] = 0;
$response['message'] = 'No faculty members found';
}}
else {
// no classrooms found
$response["success"] = 0;
$response["message"] = "Not setted";

// echo no users JSON

}


// echo no users JSON
echo json_encode($response);

?>

1 个答案:

答案 0 :(得分:0)

可能无法解决问题但是fyi-

$result3 = mysql_query("SELECT * FROM `group` where ... fID = '$FID'");

你有fID而不是FID-小写的f会抛出你的查询。