【问题标题】:insert database nusoap-complexType插入数据库 nusoap-complexType
【发布时间】:2014-05-04 07:54:08
【问题描述】:

我想从以下位置创建插入数据库 Web 服务: http://www.discorganized.com/php/a-complete-nusoap-and-flex-example-part-1-the-nusoap-server/

这是我的脚本: <pre></pre>

<?php
require_once 'lib/nusoap.php';
$client= new nusoap_client("http://127.0.0.1/test2/index.php", false);
$in_contact=array ('first_name'=>$_POST['first_name'],
                'last_name' => $_POST['last_name'],
                'email' => $_POST['email'],
                'phone_number' => $_POST['phone_number'],);
$result = $client->call('insertContact', $in_contact);
if ($result){
    echo "OK";
} else {
    echo "Error";
}
?>

尽管 ID 增加,为什么其他列仍然为空? 请帮助我,谢谢。

&lt;form&gt; 代码..

< form action="Contact.class.php" method="GET" > Nama Depan:<br> <input type="text" name="first_name"/><br> Nama Belakang:<br> <input type="text" name="last_name"/><br> Email:<br> <input type="text" name="email"/><br> Telepon:<br> <input type="text" name="phone_number"/><br><br> <input type="submit" value="Submit"/><br> < /form >

【问题讨论】:

  • 尝试在&lt;?phptag 之后添加var_dump($_POST); 以检查值是否正确映射。
  • 空输入,问题是否出在我创建的数组上?
  • 可能&lt;form&gt; 没有正确地将数据发送到您的PHP。可以显示&lt;form&gt; 代码吗?

标签: php html output nusoap


【解决方案1】:

如您所见,方法是 GET ,将其更改为 POST

像这样……

<form action="Contact.class.php" method="POST" >

固定的&lt;form&gt; 代码..你有很多缩进出错了..

<form action="Contact.class.php" method="POST" >
Nama Depan:<br> <input type="text" name="first_name"/><br>
Nama Belakang:<br> <input type="text" name="last_name"/><br>
Email:<br> <input type="text" name="email"/><br>
Telepon:<br> <input type="text" name="phone_number"/><br><br>
<input type="submit" value="Submit"/><br> </form>

【讨论】:

  • 抱歉,没有成功。
  • 您的代码上的&lt;form 之间有一个空格.. 删除它。 在答案中使用&lt;form&gt; 代码
  • Nama Depan:

    Nama Belakang :

    Email:

    Telepon:



    还是不行
【解决方案2】:
<?php
require_once 'lib/nusoap.php';
$client= new nusoap_client("http://127.0.0.1/test2/index.php", false);
$in_contact=array ('first_name'=>$_POST['first_name'],
                'last_name' => $_POST['last_name'],
                'email' => $_POST['email'],
                'phone_number' => $_POST['phone_number'],);
$result = $client->call('insertContact', array($in_contact));
if ($result){
    echo "OK";
} else {
    echo "Error";
}
?>

【讨论】:

  • 你能解释一下你的答案吗?你做了什么,为什么会奏效?
  • $result=$client->call('method',array('param1,param2'));
  • 对不起,我没有完成就点击进入。好的,如您所见,我们将首先调用已注册的方法,然后调用数组。但是,数组已经指定,因此只调用 $in_contact 作为 ($in_contact=array ('first_name'=>$_POST['first_name'], 'last_name' => $_POST['last_name'], 'email ' => $_POST['email'], 'phone_number' => $_POST['phone_number'],);)
  • 欢迎来到 Stack Overflow!请edit您的帖子添加您对答案的任何其他信息。避免在 cmets 中添加它,因为它们更难阅读并且更容易删除。 举报者/评论者: For code-only answers such as this one, downvote, don't delete!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-26
  • 1970-01-01
  • 1970-01-01
  • 2013-03-28
  • 1970-01-01
相关资源
最近更新 更多