1

私のphpコードは

<?php
    $id = $_GET['id'];

    define("__ZBXE__", true);
    include("../../files/config/db.config.php");
    $connect = @mysql_connect(localhost, kah601, kah909090);
    @mysql_select_db("kah601", $connect);
    @mysql_query("set names utf8");

$name = $_POST['name'];
$name = $_POST['ox_score'];
$name = $_POST['between_score'];
$name = $_POST['order_score'];
$name = $_POST['total_score'];


$sql = sprintf("INSERT INTO `jp_mango` (`name`, `ox_score`, `between_score`, `order_score`, `total_score` ) VALUES ('%s', '%s', '%s', '%s' , '%s');",$name, $ox_score, $between_score, $order_score, $total_score); 



$result = mysql_query($sql, $connect);

mysql_close();

?>

5 つのデータ (name、ox_score、before_score、order_score、total_score) をアップロードする必要があります。

そしてスタックオーバーフローを参考にこのコードを作りました。しかし、私はデータを投稿することはできません。ロードページを見ると、このように表示されます。(数値は自動インクリメント)

"num":"8","name":"","ox_score":"","between_score":"","order_score":"","total_score":""

この種のデータを投稿するにはどうすればよいですか? 私を助けてください。

string sendData = "";
            Uri site = new Uri("http://kah601.cafe24.com/jp_mango_writeboard.php");
            WebClient wc = new WebClient();
            wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
            sendData += "name=hello";
            sendData += "ox_score=10";
            sendData += "between_score=10";
            sendData += "order_score=10";
            sendData += "total_score=30";
            wc.Headers[HttpRequestHeader.ContentLength] = sendData.Length.ToString();
            wc.UploadStringCompleted += new UploadStringCompletedEventHandler(wc_UploadStringCompleted);
            //wc.UploadStringAsync(site, "POST", post_name, "name");
            wc.UploadStringAsync(site, "POST", sendData);
4

2 に答える 2

1

また、このように文字列形式を変更する必要があります

sendData += "name=hello";
sendData += "&ox_score=10";
sendData += "&between_score=10";
sendData += "&order_score=10";
sendData += "&total_score=30";

つまり、「&」を追加します

于 2012-10-04T11:30:29.963 に答える
0

このようなデータがあります

"num":"8","name":"","ox_score":"","between_score":"","order_score":"","total_score":""

あなたが使うべきよりも

  $newdata=json_decode($_POST['data']);

$name=$newdata->name;
$ox_store=$newdara->ox_score;
//and more...
于 2012-10-04T11:14:47.710 に答える