PHP POST下傳,無法讀取下傳的字串

來源:互聯網
上載者:User
PHP POST上傳,無法讀取上傳的字串
本地c#寫的 用WebClient類http://1.liuruitao.sinaapp.com/test.php?name={0}通過這個url上傳的,網頁那邊

if($_SERVER['REQUEST_METHOD']=="POST")
{
// $s=json_encode($_post)

$s=$_GET["name"];
echo "hello world!!";
echo $_POST["name"];
$conn=mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
if(!$conn)
die("connect fail".mysql_error());
mysql_select_db('app_liuruitao',$conn);
$sql = "insert into $db values ('3344556677',$s,3,'4',5,'6','7','8','9')";
mysql_query($sql,$conn);//借SQL語句插入資料
mysql_close();//關閉MySQL串連
echo "insert success";
}
就是無法正確擷取上傳的name裡面的字串插入到資料庫中,大家幫幫忙謝謝了


------解決方案--------------------
$sql = "insert into $db values ('3344556677',$s,3,'4',5,'6','7','8','9')";
如果 $s 無值,那麼實際執行的 SQL指令為
insert into 表名 values ('3344556677',,3,'4',5,'6','7','8','9')
顯然是錯誤的
可通過
mysql_query($sql,$conn) or die(mysql_error());
知道這種情況是否存在
另外
$sql = "insert into $db values ('3344556677',$s,3,'4',5,'6','7','8','9')";
應寫作
$sql = "insert into $db values ('3344556677','$s',3,'4',5,'6','7','8','9')";
以免意外的發生
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.