2012-02-24 120 views
0

全部! 我有PHP頁面是這樣的:POST不起作用

<?php 
if(isset($_POST['userid']) and isset($_POST['dlspeed'])) 
{ 
    $userid=$_POST['userid']; 
    $dlspeed=$_POST['dlspeed']; 
    $timestamp =date("y-m-d H:i"); 
    $db_conn = mysql_connect('localhost', "root", "asdk78623r"); 
    mysql_select_db("speedtest", $db_conn); 
    $query='INSERT INTO status VALUE (NULL, "'.$userid.'", "'.$dlspeed.'", "'.$timestamp.'")'; 
    $result=mysql_query($query,$db_conn); 
} 
? 

而且從C#我做一篇:

 HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(pageurl); 

       byte[] buffer = Encoding.ASCII.GetBytes(data); 
       System.Net.ServicePointManager.Expect100Continue = false; 
       WebReq.SendChunked = false; 
       WebReq.Expect = null; 
       WebReq.KeepAlive = false; 

       //I try also setting proxy 
       // WebReq.Proxy = new WebProxy("192.168.0.107", 3128); 
       //Our method is post, otherwise the buffer (postvars) would be useless 
       WebReq.Method = "POST"; 
       //We use form contentType, for the postvars. 
       WebReq.ContentType = "application/x-www-form-urlencoded"; 
       //The length of the buffer (postvars) is used as contentlength. 
       WebReq.ContentLength = buffer.Length; 
       //We open a stream for writing the postvars 
       Stream PostData = WebReq.GetRequestStream(); 
       //Now we write, and afterwards, we close. Closing is always important! 
       PostData.Write(buffer, 0, buffer.Length); 
       PostData.Close(); 

       //posted data is not inserted in db 
//and in follow line code Ive got error: The remote server returned an error: (417) //Expectation failed 
       HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse(); 

我做什麼了?隨着捲曲命令發佈工作正常:

curl -d "userid=SW783IC2QDHFYU6P4XKO&dlspeed=814,602968463903&timestamp=2012-2-23 19:29:33" pageurl 

任何想法,建議,重新考慮?

+1

什麼問題?錯誤?不起作用?意外的結果? – deceze 2012-02-24 09:12:42

+0

'如果(isset($ _ POST [ '用戶ID'])和isset($ _ POST [ 'dlspeed']))'可以縮短至'如果(isset($ _ POST [ '用戶ID'],$ _POST ['dlspeed 「]))' – Vitamin 2012-02-24 09:19:05

+5

我們並不需要知道關於MySQL :) – mishu 2012-02-24 09:20:26

回答

0

有多種選擇,爲什麼這會發生。

http://www.checkupdown.com/status/E417.html

其中的一個原因可能是: http://haacked.com/archive/2004/05/15/http-web-request-expect-100-continue.aspx

安裝記錄您的請求,它們包含fiddler2的偉大工程是什麼(是免費的,易於使用的程序,有幾個非常相似,但不記得他們的名字ATM)

嘗試,看看如果你發現不應該存在任何頭,如果你不能在這裏你的生活指點迷津的人可以幫助你,一旦你張貼。