我参考以下链接http://www.discorganized.com/php/a-complete-nusoap-and-flex-example-part-1-the-nusoap-server/
代码:
$client = new nusoap_client("http://localhost/jenny_flowers/online-shopping/webservice/index.php?wsdl",array('trace' => 1));
$in_contact=array ('first_name'=>'sona','last_name' => 'sdsdsd','email' => 'ssdsd','phone_number' => 'sdsd');
$result = $client->call('insertContact', $in_contact);
if ($result){ echo "OK";
} else { echo "Error";
}
但它显示
Array to string conversion in C:\wamp\www\jenny_flowers\online-shopping\webservice\lib\nusoap.php on line 7266
实际问题是什么?帮助
答案 0 :(得分:1)
首先要有连接文件
connect.php
<?php
$mysql_db_hostname = "localhost";
$mysql_db_user = "root";
$mysql_db_password = "";
$mysql_db_database = "your database";
$con = @mysqli_connect($mysql_db_hostname, $mysql_db_user, $mysql_db_password,
$mysql_db_database);
if (!$con) {
trigger_error('Could not connect to MySQL: ' . mysqli_connect_error());
}
?>
<强> insert.php 强>
<?php
include_once('connect.php');
error_reporting( error_reporting() & ~E_NOTICE );
//$first_name= $_GET['first_name'];
$last_name= $_GET['last_name'];
$email= $_GET['email'];
$phone_number= $_GET['phone_number'];
{
$insert="INSERT INTO //your_table_name(first_name,last_name,email,phone_number)values
('$first_name','$last_name','$email','$phone_number')";
$result = mysqli_query($con, $insert);
if(!$result)
{
print("invalid query");
}
else
{
$output['success']=1;
$output['message']="Insert records successfully";
print(json_encode($output));
}
}
?>
在浏览器中安装JSON Viwer以查看json输出 否则你可以在其中使用echo