android - PHP GCM Undefined Index -


on execution of function, error appears:

[23-apr-2015 01:08:39 europe/berlin] php notice: undefined index: syncnewdata in c:\xampp\index.php on line 972

for line: $pushmessagetag = isset($_post["syncnewdata"]) ? $_post["syncnewdata"] : $_post["syncnewdata"]; in function:

function updatedatagcm($db) {     // gcm regids new, "unseen" data:     $sqlallregids = 'select distinct gcm_registration_id                       users                     id in (                     select distinct myid usersid  group_messages `read` = 1                     union                     select distinct touid usersid   messages `read` = 1                     union                      select distinct invited_id usersid  event_invites `status` = 1                     union                      select distinct receiver_id usersid  group_invites `status` = 1                     union                     select distinct requestid usersid  friends `status` = 1                     )';      // execute     if ($resultids = $db->query($sqlallregids))      {          $pushmessagetag = isset($_post["syncnewdata"]) ? $_post["syncnewdata"] : $_post["syncnewdata"];          $gcmregids = array($resultids);         $message = array("syncnewdata" => $pushmessagetag);         $pushstatus = sendpushnotificationtogcm($gcmregids, $message);         return $pushstatus;      }     } 

i not understand why error occur, how alleviate?

update:

this action that, upon user sending message, send sync messages gcm:

case "sendgroupmessage":         if ($userid = authenticateuser($db, $username, $password, $gcmregid))          {                if (isset($_request['togroupid']))             {   // instead of tousername it's groupid                 $togroupname = $_request['togroupname'];                 $togroupid   = $_request['togroupid'];                   $message     = $_request['messagetext'];                 $campaign    = $_request['campaign_id'];                 $location    = $_request['location_id'];                  // query users id's in group not user sending message                         $sqlgroupmembers = "select distinct usersid users_groups                       usersid != '".$userid."' , groupid = '".$togroupid."'";                   // loop create copy of message users taht part of group                 if($getgroupmembersid = $db->query($sqlgroupmembers))                  {                     while($rowgroupmembers = $db -> fetchobject($getgroupmembersid))                     {                         $sql22 = "insert `group_messages` ..."                                           error_log("$sql22", 3 , "error_log");                         if ($db->query($sql22))                          {                              $out = successful;                          }                                        else                          {                             $out = failed;                         }                                         }                                  }                  // send gcm turn on devices:                 echo updatedatagcm($db);                              }             else             {                 $out = failed;             }                     }         else         {             $out = failed;         }        break; 

the original updatedatagcm()

worked fine:

function updatedatagcm() {      $gcmregid  =  'test id'     $pushmessage = $_post["syncnewdata"];        $gcmregids = array($gcmregid);     $message = array("syncnewdata" => $pushmessage);     $pushstatus = sendpushnotificationtogcm($gcmregids, $message);      return $pushstatus; } 

your post data doesn't include variable called syncnewdata. line:

$pushmessagetag = isset($_post["syncnewdata"]) ? $_post["syncnewdata"] : $_post["syncnewdata"]; 

which seems testing existence of variable, refer $_post['syncnewdata'] whether or not set.

you need

$pushmessagetag = isset($_post["syncnewdata"]) ? $_post["syncnewdata"] : ''; 

which return variable f exists, or empty string if doesn't


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -