Question

This is my PHP code:

<?php

  mysql_connect("localhost","root","");
  mysql_select_db("sowrun_mobile");

 $ad_id = $_REQUEST['ad_id'];
  $sql=mysql_query("SELECT * FROM tbl_user_registration where reg_AD_ID='".$ad_id."'");

  $row='';
  while($row=mysql_fetch_assoc($sql)){


    $output[]=$row;
  }

  if($row == ''){
        $out['reg_AD_ID'] = '111111';
$output[]=$out;
}



  $jsonStr = json_encode($output);
  print($jsonStr);

  mysql_close();

?>

I am trying to send the parameter adid from the Worklight adapter with the following method:

function getFeeds() {

    WL.Logger.debug("inside method");

    var input = {

        method : 'get',

        returnedContentType : 'json',

        path : "ios/ClientadID.php"

    };

ClientadID.php contains the code which is written in the first code sample above.

I am trying to send the request from the adapter with the following parameters while invoking the procedure. In the parameter window I am sending ad_id=1 but an error is throwing:

Notice: Undefined index: ad_id in C:\wamp\www\ios\ClientadID.php on line 6

Was it helpful?

Solution

I'm not sure what you mean by "In the parameter window". When you invoke a worklight adapter from the worklight studio, the parameter window that comes up is so that you can pass parameters to your adapter function, not REST parameters.

function getFeeds(myParameter) {

// myParameter is what is passed from the parameter window

WL.Logger.debug("inside method");

var input = {

    method : 'get',
    returnedContentType : 'json',
    path : "ios/ClientadID.php"

};

If you're trying to pass a parameter for a GET or POST request, then you need to change your adapter "input" object like this:

function getFeeds() {

WL.Logger.debug("inside method");

var input = {

    method : 'get',
    returnedContentType : 'json',
    path : "ios/ClientadID.php",
    parameters: {"ad_id": 1}

};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top