gpt4 book ai didi

php - 并非所有字段都插入到 MySQL 表中

转载 作者:行者123 更新时间:2023-11-29 12:50:38 25 4
gpt4 key购买 nike

我有一个简单的 SOAP 网络服务,它必须获取 3 个项目并将它们插入表中。但只插入前两个字段。怎么了?

这是服务器:

<?php
require_once '../scripts/database_connection.php';
require_once "lib/nusoap.php";
ini_set("soap.wsdl_cache_enabled", "1");

$server = new soap_server();
$server->configureWSDL("appstatus", "urn:appstatus");

$server->register('getStatus',
array("uid" => "xsd:decimal", "status" => "xsd:decimal", "comment" => "xsd:string"),
array("return" => "xsd:string"),
"urn:appstatus",
"urn:appstatus#getStatus",
"rpc",
"encoded",
"Get Status");
function getStatus($uid,$status,$comment) {
mysql_query('SET NAMES "utf8"');
$query="INSERT INTO a_test (uid, approved, comment) VALUES ('{$uid}','{$status}','{$comment}')";
mysql_query($query);
}

$server->service($HTTP_RAW_POST_DATA);

这是客户:

<?php 
require_once ('lib/nusoap.php');
ini_set("soap.wsdl_cache_enabled", "0");
//$result=$client->call('getStatus' array ('uid'=>3,'status'=>1));
$param = array( 'uid' => '33','status'=>'1','comment' => 'some comment');
$uid=$param['uid'];
$status=$param['status'];
$comment=$param['comment'];
$client = new nusoap_client('http://localhost/webservice/getstatus.php?wsdl');
$response = $client->call('getStatus',$param);
if($client->fault)
{
echo "FAULT: <p>Code: (".$client->faultcode."</p>";
echo "String: ".$client->faultstring;
}
else
{
echo 'OK';
}
?>

最佳答案

您在 SQL 查询中有一个拼写错误,第三个参数不是变量:

   $query="INSERT INTO a_test (uid, approved, comment) VALUES    
('{$uid}','{$status}','comment')";

替换为:

   $query="INSERT INTO a_test (uid, approved, comment) VALUES 
('{$uid}','{$status}','{$comment}')";

关于php - 并非所有字段都插入到 MySQL 表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24798671/

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