This is an UPDATE on my progress, still getting a sympathetic error:
So basically I am not getting return data from my nuSOAP web service when calling a function using mySQLi query
I think due to nuSOAP (there is no evidence yet), anyway, here is the code with nuSOAP in it:
<?php // include the SOAP classes require_once('nuSOAP/lib/nusoap.php'); $host = 'mysql13.000webhost.com'; $user = 'a8434864_updater'; // MySQL login username $pass = '***'; // MySQL login password $database = 'a8434864_lokiupd'; // Database name $con=mysqli_connect($host,$user,$pass,$database); // Check connection if (mysqli_connect_errno($con)) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } function OnlineStatus(){ return true; } function GetRegTitle(){ global $con; $SQL = "SELECT app_reg_title FROM a8434864_lokiupd._misc WHERE id = 0"; $result = mysqli_query($con,$SQL); // ERROR LINE 26 if(!$result) { die(mysqli_error($con)); // ERROR LINE 28 } $row = mysqli_fetch_row($result); return $row[0]; } mysqli_close($con); // create the server object $server = new nusoap_server(); // Initialize WSDL support $server->configureWSDL('userdatawsdl', 'urn:userdatawsdl'); $server->register('OnlineStatus', array(), array('result' => 'xsd:boolean')); $server->register('GetRegTitle', array(), array('result' => 'xsd:string')); if (isset($error)) { $fault = $server->fault('soap:Server','',$error); } // send the result as a SOAP response over HTTP $HTTP_RAW_POST_DATA $post = file_get_contents('php://input'); $server->service($post); ?>
On the client side (the client that I am not using for me is the SOA Client plugin for firefox), this is the error I get:
PHP error message
Warning : mysqli_query (): Failed to get mysqli in /home/a8434864/public_html/webservice/webservice.php online 26
PHP error message
Warning : mysqli_error () [function.mysqli-error]: could not get mysqli in /home/a8434864/public_html/webservice/webservice.php online 28
However, this code works flawlessly (it is the same as above, but without nuSOAP):
<?php $host = 'mysql13.000webhost.com'; // Host name Normally 'LocalHost' $user = 'a8434864_updater'; // MySQL login username $pass = '***'; // MySQL login password $database = 'a8434864_lokiupd'; // Database name $con=mysqli_connect($host,$user,$pass,$database); // Check connection if (mysqli_connect_errno($con)) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } function OnlineStatus(){ return true; } function GetRegTitle(){ global $con; $SQL = "SELECT app_reg_title FROM _misc WHERE id = 0"; $result = mysqli_query($con,$SQL); if(!$result) { die(mysqli_error($con)); // TODO: better error handling } $row = mysqli_fetch_row($result); return $row[0]; } echo '1:<br>'; print_r(OnlineStatus()); echo '<br>2:<br>'; print_r(GetRegTitle()); mysqli_close($con); ?>
What can anyone help me?