當我嘗試從Android的數據發送到PHP中,我得到的logcat這些黃色警告:當發送數據到PHP logcat的警告
無效使用SingleClientConnManager的:仍然分配的連接
和:
W/SingleClientConnManager(274):請確保在分配另一個連接之前釋放連接。
我的代碼是這樣的:
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("email", ""));
InputStream is=null;
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://zzzzz.com/zzz.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
httpclient.execute(httppost);
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is=entity.getContent();
} catch (IOException e) {
}
在我zzz.php我:
<?php
$email = "aaa";
if (session_id() == "")
{
session_start();
}
if (!isset($_SESSION['username']))
{
header('Location: ./index.php');
exit;
}
else
{
$username = "******";
$password = "****";
$host = "****";
$database = "****";
$db = mysql_connect($host, $username, $password);
if (!$db)
{
die('Failed to connect to database server!<br>'.mysql_error());
}
else
{
mysql_select_db($database, $db) or die('Failed to select database<br>'.mysql_error());
mysql_query("UPDATE Users SET lat='".$email."' WHERE username='{$_SESSION['username']}'");
}
}
?>
順便說一句,我知道的mysql_query過時了,我會改變它。 無論如何上面的代碼不起作用。我的意思是它不會在MySQL中對緯度值寫「aaa」。哪裏錯了?
如果我用瀏覽器連接筆記本電腦沒有錯誤。它工作良好。但如果我連接我的android手機有logcat上的警告。 – Ozan