-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"));

        ?>
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
denzo kx
  • 51
  • 1
  • 6

1 Answers1

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