-1

i'm trying to get a list of data from my database using a NuSoap web service .

But when i execute , i get this error message :

Notice:  Array to string conversion in C:\wamp64\www\gcm\database.php on line 105
PHP Warning:  mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\wamp64\www\gcm\database.php on line 112

I tested the function below in web page and i get the result (array table) :

Array ( [0] => Array ( [titre] => list des docs [dateHeure] => 2018-04-16 [detail] => hello ) )

This is my function :

function getHistoriqueNotification(){
$com = new DbConnect();
$message=array();
$sql = "select alr_alertes.TITRE,alr_alertes.PHOTO,alr_historiques.DETAIL,alr_historiques.DATEHEURE,alr_alertes.CODE from alr_alertes,alr_historiques WHERE alr_alertes.ALRT_UID=alr_historiques.ALRT_UID" ;
$result = mysqli_query($com->getDb(),$sql);
while($row=mysqli_fetch_assoc($result)){
  $message[] = array(

      'titre'     =>$row['TITRE'], 
      'dateHeure' =>$row['DATEHEURE'],
      'detail'    =>$row['DETAIL'],
      'code'      =>$row['CODE']
    );
}
return ($message);
}

Implementation of my Web service :

<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
 require_once 'config.php';
require_once 'database.php';
// Create the server instance
$server = new soap_server();
$server->configureWSDL('Myservice_wsdl', 'urn:Myservice_wsdl');
$server->soap_defencoding = 'UTF-8';

$server->wsdl->addComplexType('Notifications',
    'complexType',
    'struct',
    'all',
    '',
    array(
            'titre' => array('name' => 'titre', 'type' => 'xsd:string'),
            'dateHeure' => array('name' => 'dateHeure', 'type' => 'xsd:date'),
            'detail' => array('name' => 'detail', 'type' => 'xsd:string'),
            'code' => array('name' => 'code' , 'type' => 'xsd:string')
)
);
$server->wsdl->addComplexType('notificationArray',
    'complexType',
    'array',
    '',
    'SOAP-ENC:Array',
    array(),
    array(
            array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:Notifications[]')
    ),
'tns:Notifications'
);
$server->register('getHistoriqueNotification',
                        array(),
                        array('result' =>'tns:notificationArray'),
                          'urn:MyService_wsdl',
                        'urn:MyService_wsdl#getHistoriqueNotification',
                        'rpc',
                        'encoded',
                        'Some comments about function 1'


                      );
 $server->service(file_get_contents("php://input"));

        ?>

1 Answer 1

0

I think thet your lib DbConnect is broken. It returns some thing incorrect as we can see:

Notice:  Array to string conversion in C:\wamp64\www\gcm\database.php on line 105

and then mysqli_query gets false in $sql instead of mysqli_result

Sign up to request clarification or add additional context in comments.

1 Comment

No , it's working , as i said i tested the function and it worked in a php page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.