I am trying to implement a web service using PHP. I am following xml-rpc protocol.
I am trying to call a function through index file and display records from the database but when i try to call the function in file server2 nothing is printed on the screen just a blank white screen is showed up here is my code so far.
Kindly help me out with this I have spent hours searching about this but cannot find any help
server2.php
<?php
$request_xml = file_get_contents("php://input");
function say_hello($method_name, $args) {
$dbLink = mysqli_connect('localhost','root','saad','enstructo');
if (!$dbLink) {
echo "ERROR";
}
$query = "SELECT * FROM Admin";
if ($result = mysqli_query($dbLink,$query)) {
while($getquery = mysql_fetch_array($result)){
$returnquery[] =array($result['username'],$result['email']) ;
}
}
return $returnquery;
}
$xmlrpc_server = xmlrpc_server_create();
xmlrpc_server_register_method($xmlrpc_server, "say_hello", "say_hello");
header('Content-Type: text/xml');
print xmlrpc_server_call_method($xmlrpc_server, $request_xml, array());
?>
index.php
<?php
$request = xmlrpc_encode_request("say_hello", array('10'));
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml
User-Agent: PHPRPC/1.0
",
'content' => $request
)));
$server = 'http://localhost/rpc/basic/server2.php';
$file = file_get_contents($server, false, $context);
$response = xmlrpc_decode($file);
echo $response;
?>