gpt4 book ai didi

php - 使用 nusoap Web 服务将数据插入 MySql?

转载 作者:行者123 更新时间:2023-11-30 01:12:00 25 4
gpt4 key购买 nike

我创建了此代码来使用 nusoap 将数据插入到我的数据库中。一切工作正常,但数据未插入我的数据库中。

这是代码

require_once('nusoap/nusoap.php');

$server = new soap_server();

$server->configureWSDL('Insert Order', 'urn:InsertOrder');

$server->soap_defencoding = 'utf-8';

$server->register(
'InsertOrder',
array('FirstName' => 'xsd:Testing', 'LastName' => 'xsd:NuSoap'),
array('return' =>'xsd:boolean'),
'urn:InsertOrderwsdl',
'urn:InsertOrderwsdl#InsertOrder',
'rpc',
'literal'
);

function InsertOrder($FirstName, $LastName) {

$connect = mysql_pconnect("localhost","root","");
if ($connect) {
if(mysql_select_db("database", $connect)) {
mysql_query("INSERT INTO myuser SET FirstName='$FirstName', LastName='$LastName'");
return true;
}
}
return false;
}

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

这是 wsdl 文件:

<definitions targetNamespace="urn:InsertOrder">
<types>
<xsd:schema targetNamespace="urn:InsertOrder">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
</xsd:schema></types>
<message name="InsertOrderRequest">
<part name="FirstName" type="xsd:Testing"/>
<part name="LastName" type="xsd:NuSoap"/>
</message>
<message name="InsertOrderResponse">
<part name="return" type="xsd:boolean"/>
</message><portType name="Insert OrderPortType">
<operation name="InsertOrder">
<input message="tns:InsertOrderRequest"/>
<output message="tns:InsertOrderResponse"/>
</operation>
</portType>
<binding name="Insert OrderBinding" type="tns:Insert OrderPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="InsertOrder">
<soap:operation soapAction="urn:InsertOrderwsdl#InsertOrder" style="rpc"/>
<input>
<soap:body use="literal" namespace="urn:InsertOrderwsdl"/>
</input>
<output>
<soap:body use="literal" namespace="urn:InsertOrderwsdl"/>
</output>
</operation></binding>
<service name="Insert Order">
<port name="Insert OrderPort" binding="tns:Insert OrderBinding">
<soap:address location="http://localhost/nuSoap/MyService.php"/>
</port>
</service>
</definitions>

在 wsdl 文件中参数和输出正常。我不明白为什么不将这些数据放入我的数据库中?我一定想念这里的一些东西。任何人都知道为什么会发生这种情况?预先感谢您。

最佳答案

您的插入语句看起来更像是更新语句。你能改变一下吗

mysql_query("INSERT INTO myuser SET FirstName='$FirstName',     LastName='$LastName'");

mysql_query("INSERT INTO myuser(FirstName,LastName) values('$FirstName', '$LastName')");

关于php - 使用 nusoap Web 服务将数据插入 MySql?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19389907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com