PHP:使用客户端从mysql中读取表的麻烦

时间:2017-06-05 18:33:27

标签: php mysql

我正在使用Web服务,在服务器中我使用PHP来创建函数,客户端是HTML页面

这是WebService

    <?Php

Require_once "lib / nusoap.php";

// the server and application connection
    $My_user = "root";
    $My_password = "";
    $Address = "localhost";
    $Mi_bd = "phpws";

$Connection = mysqli_connect ($address, $My_user, $My_password, $my_bd)
Or die ("can not connect to database" .mysql_error ());


// start Show books
Function ShowBooks ()
{
    $Query = "SELECT * FROM books";
    $QueryResult = mysqli_query ($connection, $query);

    While ($registerTable = mysqli_fetch_array ($QueryResult))
    {
        $ArrayTable [] = $registerTable;
        
    }
    Var_dum ($arrayTable);

    Return $arrayTable;
    

} // finish show Books

Function ShowPlanets ()
{
$Planets = "According to the definition mentioned, the solar system consists of"; // test information
Return $planets;
} // end of function that displays a message


// This condition assures us the compatibility of the values ​​of the web service
If (! Isset ($HTTP_RAW_POST_DATA))
$HTTP_RAW_POST_DATA = file_get_contents ('php: // input'); // we obtain the values ​​that are read in the web service
 // end to check if it is empty


$Server = new soap_server ();
$Server-> register ("ShowPlanets");
$Server-> register ("ShowBooks");
$Server-> service ($HTTP_RAW_POST_DATA);
exit;

?>

此函数执行以下操作,在数据库中运行查询并为客户返回一个数组,&#34;客户端&#34;在页面中打印数组但是

<?Php
     Require_once "lib / nusoap.php"; // reference of a library to use one of its internal functions

     // the bottom line makes an installation of the web service and we create an object called client that uses the web service
     $client = new nusoap_client ("http: //localhost/04_soap_mysql/soap_server.php");

     $Books = $client-> call ("ShowBooks"); // service call
     $Planets = $client-> call ("ShowPlanet");
     // row printing
     Echo "<h2> My books </ h2>";
     Echo "<ul>";

     Echo $planets;
    
     Foreach ($Books as $item)
     {
         Echo '<li>';
         Echo '<strong>'. $ Item ['autor']. '</ Strong> <br>';
         Echo $ item ['titulo'];
         Echo '<br> <br> </ li>';
     }
    
        
      Echo "variable type:";
      Var_dump ($Books);

?>
  

麻烦:客户端显示下一条消息

警告:在第14行的C:\ xampp \ htdocs \ 04_soap_mysql \ index.php中为foreach()提供的参数无效 tipo de variable:bool(false)

0 个答案:

没有答案