我正在开发一个与服务器通信并将信息写入数据库的Android应用程序。我有应用程序连接到数据库,但必须有一些错误w /我的查询b / c我一直收到我正在回应的错误消息。我试图发布的表有6列,其中一列是关键。
我认为Android方面没有任何问题,但这是我发送信息的方式:
<li id="item-mzm6820mzm2mzmNaNmzmdk" class="list-group-item hand">
<div class="row">
<div class="col-md-2">
<img src="/images/6820.jpg" class="img-responsive">
</div>
<div class="col-md-10">
Alu værksteds donkraft 2,5 T.<br/>
Varenummer: 6820 </div>
</div>
</li>
<li id="item-mzm6815mzm2mzmNaNmzmdk" class="list-group-item hand">
<div class="row">
<div class="col-md-2">
<img src="/images/6815.jpg" class="img-responsive">
</div>
<div class="col-md-10">
Alu værksteds donkraft 1,25 T.<br/>
Varenummer: 6815 </div>
</div>
</li>
<li id="item-mzmR6815-21mzm2mzmNaNmzmdk" class="list-group-item hand">
<div class="row">
<div class="col-md-2">
<img src="/images/1463467375.jpg" class="img-responsive">
</div>
<div class="col-md-10">
Kardanled for 1,25 ton donkraft. <br/>
Varenummer: R6815-21 </div>
</div>
</li>
<li id="item-mzmR6820-UJmzm2mzmNaNmzmdk" class="list-group-item hand">
<div class="row">
<div class="col-md-2">
<img src="/images/1463467386.jpg" class="img-responsive">
</div>
<div class="col-md-10">
Kardanled for 2,5 ton donkraft. <br/>
Varenummer: R6820-UJ </div>
</div>
</li>
<li id="item-mzmR6815-pakmzm2mzmNaNmzmdk" class="list-group-item hand">
<div class="row">
<div class="col-md-2">
<img src="/images/1463466442.jpg" class="img-responsive">
</div>
<div class="col-md-10">
Olie pakning kit sæt for 1,25 ton donkraft.<br/>
Varenummer: R6815-pak </div>
</div>
</li>
<li id="item-mzmR6820-pakmzm2mzmNaNmzmdk" class="list-group-item hand">
<div class="row">
<div class="col-md-2">
<img src="/images/1463466450.jpg" class="img-responsive">
</div>
<div class="col-md-10">
Olie pakning kit sæt for 2,5 ton donkraft.<br/>
Varenummer: R6820-pak </div>
</div>
</li>
<li id="item-mzmR6815-1mzm2mzmNaNmzmdk" class="list-group-item hand">
<div class="row">
<div class="col-md-2">
<img src="/images/1463467321.jpg" class="img-responsive">
</div>
<div class="col-md-10">
Gummiplade for 1,25 ton donkraft.<br/>
Varenummer: R6815-1 </div>
</div>
</li>
<li id="item-mzmR6820-1mzm2mzmNaNmzmdk" class="list-group-item hand">
<div class="row">
<div class="col-md-2">
<img src="/images/1463467331.jpg" class="img-responsive">
</div>
<div class="col-md-10">
Gummiplade for 2,5 ton donkraft.<br/>
Varenummer: R6820-1 </div>
</div>
</li>
这是我正在使用的PHP脚本:
URL url = new URL(URL_);
HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
OutputStream outputStream = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, UTF));
String data =
URLEncoder.encode(USER_ID, UTF) + "=" + URLEncoder.encode(_id, UTF) + "&" +
URLEncoder.encode(PRIMARY_INFO, UTF) + "=" + URLEncoder.encode(primary, UTF) + "&" +
URLEncoder.encode(SECONDARY, UTF) + "=" + URLEncoder.encode(secondary, UTF) + "&" +
URLEncoder.encode(THIRD, UTF) + "=" + URLEncoder.encode(third, UTF) + "&" +
URLEncoder.encode(TIMESTAMP, UTF) + "=" + URLEncoder.encode(time_stamp, UTF);
bufferedWriter.write(data);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));
String response = "";
String line = "";
while ((line = bufferedReader.readLine())!=null)
{
response+= line;
}
bufferedReader.close();
inputStream.close();
httpURLConnection.disconnect();
return response;