无法更新mysql远程数据库

时间:2013-02-13 14:04:05

标签: php android mysql json

我正在尝试使用php和json在1and1上更新mysql数据库。 数据库正在更新,但记录为空。它无法获得这些价值。 这就是我想要的。

            JSONObject json = new JSONObject();
            json.put("name", name);
            json.put("address", address);

            HttpParams httpParams = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParams,10000);
            HttpConnectionParams.setSoTimeout(httpParams, 10000);
            HttpClient client = new DefaultHttpClient(httpParams);

            HttpPost request = new HttpPost(url_create_product);
            request.setEntity(new ByteArrayEntity(json.toString().getBytes("UTF8")));
            request.setHeader("json", json.toString());
            HttpResponse response = client.execute(request);
            HttpEntity entity = response.getEntity();

Php代码

<?php
include("config.php");

// Get values from form 
$name=$_POST['name'];
$address=$_POST['address'];

// Insert data into mysql 

$sql="INSERT INTO registration(name, address)VALUES('$name', '$address')";

$result=mysql_query($sql);

if($result){
echo "<strong> <font size='18'>Done!</font></strong>";
}
else {
echo "ERROR";
}
?>


<?php 
// close connection 
mysql_close();
?>

我在这里错过了什么?

0 个答案:

没有答案