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.

Recommended Answers

All 2 Replies

Member Avatar for diafol

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.

$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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.