Home >Backend Development >PHP Tutorial >PHP POST下传,无法读取下传的字符串

PHP POST下传,无法读取下传的字符串

WBOY
WBOYOriginal
2016-06-13 11:17:261097browse

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')";
以免意外的发生
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn