我的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,between_score,order_score,total_score)。
我从堆栈溢出引用了这段代码。 但我无法发布数据。 当我看到加载页面时,就像这样显示。 (num是自动递增的)
"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);
答案 0 :(得分:1)
此外,您还必须像这样修改字符串格式
sendData += "name=hello";
sendData += "&ox_score=10";
sendData += "&between_score=10";
sendData += "&order_score=10";
sendData += "&total_score=30";
即添加'&amp;'
答案 1 :(得分: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...