0

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

4

1 回答 1

2

我不确定“在参数窗口中”是什么意思。当您从 Worklight Studio 调用 Worklight 适配器时,会出现参数窗口,以便您可以将参数传递给适配器函数,而不是 REST 参数。

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"

};

如果您尝试为 GET 或 POST 请求传递参数,则需要更改适配器“输入”对象,如下所示:

function getFeeds() {

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

var input = {

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

};
于 2013-07-24T15:30:29.143 回答