0
function addUsers($params) {
      $fnameval = $params->getParam(0);
    $fname = $fnameval->scalarval();
    $mnameval = $params->getParam(1);
    $mname = $mnameval->scalarval();
    $lnameval = $params->getParam(2);
    $lname = $lnameval->scalarval();
    if(mysql_query("INSERT INTO users(fname,mname,lname) VALUES('$fname','$mname','$lname')")){
     $mess="data and synced successfully";}
     else{
     $mess="data saved but not synced as required";}
    $response = array('response' => new xmlrpcval($mess, 'string'));
    return new xmlrpcresp(new xmlrpcval($response, 'struct'));
}

Look at the above code. I intended to implement XML-RPC(xml remote procedure call) using php. the problem is that it takes time to parse a variable(see peocedure of getting $fname). is there a shorter way i can get the vairables directly e.g $fname=$params['fname'] without getting index then scalarval() ? help.
thanks.

Edited by pritaeas: Moved.

2
Contributors
2
Replies
15
Views
4 Years
Discussion Span
Last Post by mogaka
0

are you passing params as a StdObject?

If using StdObject - I think it's a bit fussy. From where are you getting this data (params)? If from json_decode there is a boolean second parameter - set this to 'true' and you have an associative array instead of the stdobject.

More info please.

0
$params = new xmlrpcmsg('users_add',
                         array(new xmlrpcval('firstname', 'string'),
                               new xmlrpcval('middlename', 'string'),
                               new xmlrpcval('lastname', 'string')));

the source of $params is s shown above. note that values i have put are direct strings,I real scenarion,they can be like $firstname.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.