- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
情况
我正在使用 mysql 数据库。查询从 phpmyadmin 和 postman 运行
但是当我从 android 发送请求时(它返回零行)
我已经记录了从 android 发送的电子邮件是正确的并且适用于其他查询但不是这个
public function isUserExists($email, $u_name) {
$stmt = $this->conn->prepare("select * from login where email_id = ?");
$stmt->bind_param("s",$email);
$stmt->execute();
$stmt->store_result();
$num_rows = $stmt->num_rows; //getting no of rows if exits
$stmt->close();
return $num_rows > 0;
}
câu hỏi
为什么这不起作用,即使正确的电子邮件是从 android 发送并在 php 中成功获取它
我们从 android 发送的电子邮件在所有其他查询和方法中都能完美运行
biên tập我正在使用这个类来发送我的帖子请求
public class WebConnector {
String boundary = "-------------" + System.currentTimeMillis();
private static final String LINE_FEED = "\r\n";
private static final String TWO_HYPHENS = "--";
private StringBuilder url;
private String api_key;
private HashMap params = new HashMap<>();
File file;
private int count = 0;
private DataOutputStream dos;
JSONObject postData;
public void addParams(String key , String value) {
params.put(key,value);
}
public WebConnector(StringBuilder url, String api_key)
{
this.url = url;
this.api_key = api_key;
this.postData = new JSONObject();
this.file = null;
}
public WebConnector(StringBuilder url, String api_key, JSONObject postData)
{
this.url = url;
this.api_key = api_key;
this.postData = postData;
this.file = null;
}
public WebConnector(StringBuilder url, String api_key, JSONObject postData, File image) {
siêu();
this.url = url;
this.postData = postData;
this.api_key = api_key;
this.file = image;
}
public String connectToMULTIPART_POST_service(String requestMethod) {
createServiceUrl();
System.out.println(">>>>>>>>>url : " + url);
String strResponse = "";
InputStream inputStream = null;
HttpURLConnection urlConnection = null;
thử {
urlConnection = (HttpURLConnection) new URL(url.toString()).openConnection();
urlConnection.setRequestProperty("Content-Type", "application/json");
urlConnection.setRequestProperty("Connection", "close");
urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0 ( compatible ) ");
urlConnection.setRequestProperty("Authorization", "" + api_key);
urlConnection.setRequestMethod(requestMethod);
if(requestMethod.equals("GET") || requestMethod.equals("DELETE"))
urlConnection.setDoOutput(false);
else {
urlConnection.setRequestProperty("Content-type", "multipart/form-data; boundary=" + boundary);
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.setUseCaches(false);
urlConnection.setChunkedStreamingMode(1024);
dos = new DataOutputStream(urlConnection.getOutputStream());
Iterator keys = postData.keys();
while (keys.hasNext()) {
thử {
String id = String.valueOf(keys.next());
addFormField(id, postData.get(id).toString());
System.out.println(id + " : " + postData.get(id));
} bắt (JSONException e) {
e.printStackTrace();
}
}
thử {
dos.flush();
} bắt (IOException e) {
e.printStackTrace();
}
if (file != null)
addFilePart("url", file);
build();
}
urlConnection.connect();
int statusCode = 0;
thử {
urlConnection.connect();
statusCode = urlConnection.getResponseCode();
} catch (EOFException e1) {
if (count < 5) {
urlConnection.disconnect();
đếm++;
String temp = connectToMULTIPART_POST_service(requestMethod);
if (temp != null && !temp.equals("")) {
return temp;
}
}
} bắt (IOException e) {
e.printStackTrace();
}
// 200 represents HTTP OK
if (statusCode >=400) {
inputStream = new BufferedInputStream(urlConnection.getErrorStream());
strResponse = readStream(inputStream);
} khác {
System.out.println(urlConnection.getResponseMessage());
inputStream = new BufferedInputStream(urlConnection.getInputStream());
strResponse = readStream(inputStream);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
thử {
if (null != inputStream)
inputStream.close();
} bắt (IOException e) {
}
}
return strResponse;
}
public void addFormField(String fieldName, String value) {
thử {
dos.writeBytes(TWO_HYPHENS + boundary + LINE_FEED);
dos.writeBytes("Content-Disposition: form-data; name=\"" + fieldName + "\"" + LINE_FEED + LINE_FEED/*+ value + LINE_FEED*/);
/*dos.writeBytes("Content-Type: text/plain; charset=UTF-8" + LINE_FEED);*/
dos.writeBytes(value + LINE_FEED);
} bắt (IOException e) {
e.printStackTrace();
}
}
public void addFilePart(String fieldName, File uploadFile) {
thử {
dos.writeBytes(TWO_HYPHENS + boundary + LINE_FEED);
dos.writeBytes("Content-Disposition: form-data; name=\"" + fieldName + "\";filename=\"" + uploadFile.getName() + "\"" + LINE_FEED);
dos.writeBytes(LINE_FEED);
FileInputStream fStream = new FileInputStream(uploadFile);
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
int length = -1;
while ((length = fStream.read(buffer)) != -1) {
dos.write(buffer, 0, length);
}
dos.writeBytes(LINE_FEED);
dos.writeBytes(TWO_HYPHENS + boundary + TWO_HYPHENS + LINE_FEED);
/* close streams */
fStream.close();
} bắt (IOException e) {
e.printStackTrace();
}
}
public void addHeaderField(String name, String value) {
thử {
dos.writeBytes(name + ": " + value + LINE_FEED);
} bắt (IOException e) {
e.printStackTrace();
}
}
public void build() {
thử {
dos.writeBytes(LINE_FEED);
dos.flush();
dos.close();
} bắt (IOException e) {
e.printStackTrace();
}
}
private static String readStream(InputStream in) {
StringBuilder sb = new StringBuilder();
thử {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String nextLine = "";
while ((nextLine = reader.readLine()) != null) {
sb.append(nextLine);
}
/* Close Stream */
if (null != in) {
ghim theo();
}
} bắt (IOException e) {
e.printStackTrace();
}
return sb.toString();
}
private void createServiceUrl() {
if (null == params) {
return;
}
final Iterator<>> it = params.entrySet().iterator();
boolean isParam = false;
while (it.hasNext()) {
final Map.Entry mapEnt = (Map.Entry) it.next();
url.append(mapEnt.getKey());
url.append("=");
thử {
url.append(URLEncoder.encode(mapEnt.getValue(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (NullPointerException e) {
e.printStackTrace();
}
url.append("&");//%20
isParam = true;
}
if (isParam) {
url.deleteCharAt(url.length() - 1);
}
}
//localhost/LumnuOirtal/event?event=1&descip=wdsdsdsd&
}
1 Câu trả lời
我认为问题出在“bindParam”语句中。你的声明说要替换“s”而不是“?”。试试这个:
$stmt = $this->conn->prepare("select * from login where email_id = ?");
$stmt->bind_param("?",$email);
hoặc
$stmt = $this->conn->prepare("select * from login where email_id = :email");
$stmt->bind_param(":email",$email);
关于php - 查询从 postman 和 phpmyadmin 运行,但不是从 android 运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38849604/
Gần đây tôi đã thêm một số tệp .gif vào /drawable để có thể sử dụng chúng với các nút. Cách này hoạt động tốt (không có lỗi). Bây giờ khi tôi xây dựng lại/chạy ứng dụng của mình, tôi nhận được lỗi sau: Lỗi: Gradle: Đang thực thi
Có phương pháp nào trong Android để trả về đường dẫn dữ liệu lưu trữ nội bộ không? Tôi có 2 điện thoại thông minh Android (Samsung S2 và S7 Edge) mà tôi đã cài đặt một ứng dụng. Tôi muốn sử dụng sqlit nằm trong đường dẫn này
Câu hỏi này đã có câu trả lời tại đây: Sự khác biệt giữa "?android:" và "@android:" trong tệp xml bố cục Android là gì
Tôi chỉ muốn biết sự khác biệt thực sự giữa điện thoại Android phát triển, điện thoại Android gốc và điện thoại Android gốc. Chúng tôi không thể mua bộ công cụ phát triển từ cửa hàng thực tế hoặc bất kỳ nơi nào khác ngoại trừ Android Marketplace.
Tôi đang cố gắng đưa dự án này lên chuẩn mực kể từ khi Gradle được cập nhật. Đây là một dự án nhóm và sử dụng plugin android-apt. Tôi đã thực hiện các thay đổi cú pháp cần thiết (bộ xử lý biên dịch->thực hiện và apt->chú thích), nhưng trình biên dịch vẫn báo với tôi là có
Tôi mới làm quen với Android và Kotlin nên xin lỗi vì một vấn đề rất đơn giản cần giải quyết! Tôi đã tạo một ứng dụng cơ bản bằng cách sử dụng Navigation Architecture Component, sử dụng thanh điều hướng ở dưới cùng và ba tùy chọn điều hướng. Mỗi tùy chọn điều hướng sẽ trỏ tới một đoạn chuyên dụng.
Hiện tại tôi đang sử dụng SDK chính thức của Facebook dành cho Android. Tôi đang sử dụng ứng dụng mẫu nâng cao nhưng tôi không biết cách để nó lấy tường ứng dụng/luồng/trạng thái thay vì người dùng đã đăng nhập. Liệu điều này có thể thực hiện được không? Trong tình huống đó
Tôi gặp vấn đề khi tải tệp xuống, tôi có thể tải tệp xuống trong trình giả lập nhưng lại không tải được trên điện thoại của tôi. Tôi đã xác định quyền truy cập Internet và ghi vào thẻ SD. Tôi có một tệp doc trên máy chủ, nếu người dùng nhấp vào tải xuống. Nó tải tập tin xuống. Điều này hoạt động tốt trong trình mô phỏng nhưng
Câu hỏi này đã có câu trả lời ở đây: Sự khác biệt giữa gravity và layout_gravity trong Android là gì? (22 câu trả lời) Đã đóng 9
Có ai có thể cho tôi biết bộ nhớ đệm Android và bộ nhớ đệm ứng dụng là gì không vì khi chúng ta nói về ứng dụng dọn bộ nhớ đệm thì nó làm gì, khái niệm dọn bộ nhớ đệm là để dọn bộ nhớ đệm ứng dụng hay giống như quản lý bộ nhớ lưu trữ chính, RAM, bộ nhớ đệm khác nhau và theo như tôi biết thì bộ nhớ đệm
Giả sử các ứng dụng Foo và Eggs nằm trên cùng một thiết bị Android. Bất kỳ ứng dụng nào cũng có thể nhận được danh sách tất cả các ứng dụng trên thiết bị. Liệu một ứng dụng có thể biết được ứng dụng khác đã chạy hay chưa và chạy trong bao lâu không? 1 Câu trả lời
Tôi hơi bối rối, tôi chỉ thấy ví dụ từ Android sang PC hoặc ngược lại. Tôi cần tạo một ứng dụng Android để kết nối hai điện thoại (Android) để trò chuyện video. Tôi đang nghĩ, tôi biết
Được sử dụng để khóa màn hình theo chương trình bằng Android. Tôi có một số ý tưởng hay từ những câu hỏi trước đây về vấn đề này trên Stackoverflow và tôi đã làm khá tốt, nhưng khi tôi chạy đoạn mã đó, không có ngoại lệ hay lỗi nào cả. Ngoài ra, màn hình không bị khóa. Xin hãy sử dụng đoạn văn này
Tài liệu nói rằng: android:layout_alignParentStart Nếu đúng, làm cho cạnh bắt đầu của chế độ xem này khớp với cạnh bắt đầu
Tôi không biết sự khác biệt giữa hai tính chất và chiều cao này. Lấy TextView làm ví dụ, nếu tôi đặt layout_width thành wrap_content và đặt chiều rộng thành 50 dip, điều gì sẽ xảy ra? 1 Câu trả lời
Hai tính chất này liên quan với nhau như thế nào? Nếu tôi có android:noHistory="true", thì việc có android:finishOnTaskLaunch="true" có ý nghĩa gì không? Câu trả lời tốt nhất giả định rằng bạn có
Tôi mới làm quen với Android và đang cố gắng hiểu mã XML sau: Khi xem tài liệu trên developer.android.com, bạn sẽ thấy "starStyle" là hằng số trong R.attr, public static final
Trong đoạn mã sau, tại sao giao diện của nút radio lại thay đổi khi tôi đặt android:layout_width="fill_parent" và android:width="fill_parent" Tôi đang nói
Thật khó để biết nên hỏi gì ở đây. Câu hỏi này mơ hồ, không đầy đủ, quá rộng hoặc mang tính tu từ và không thể trả lời hợp lý theo hình thức hiện tại. Để được trợ giúp làm rõ vấn đề này để có thể mở lại, hãy truy cập trung tâm trợ giúp. Đóng 9
Giả sử tôi có một hàm fun myFunction(name:String, email:String){}, khi tôi gọi hàm này myFunction('Ali', 'ali@test.com ') thì thế nào
Tôi là một lập trình viên xuất sắc, rất giỏi!