PHP:使用客户端从mysql读取表时遇到问题
我使用的是一个web服务,在服务器上我使用PHP生成函数,客户端是HTML页面 这是WebServicePHP:使用客户端从mysql读取表时遇到问题,php,mysql,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
<?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;
?>
此函数执行以下操作:在数据库中运行查询并为客户返回一个数组,“客户机”在页面中打印该数组,但
<?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\u soap\u mysql\index.php中为foreach()提供的参数无效
tipo de variable:bool(false)大概
$Books
是null还是不是数组?也许可以使用另一个工具,如Fiddler,查看您的服务实际返回了什么。顺便说一句,JSON web服务比SOAP服务痛苦得多,IMO。谢谢你,我正在学习web服务,这是关于这方面的第一门课程,我已经下载了软件,但现在我要看看这个工具能做什么