Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 插入查询在SQL中工作,但不使用';无法从android应用程序工作_Java_Php_Android_Database - Fatal编程技术网

Java 插入查询在SQL中工作,但不使用';无法从android应用程序工作

Java 插入查询在SQL中工作,但不使用';无法从android应用程序工作,java,php,android,database,Java,Php,Android,Database,我正在尝试向我的SQL数据库发送一个INSERT查询,但它不起作用,并且没有出现错误,但是如果我从phpMyAdmin发送查询,它会起作用。 以下是我的PHP代码: if ($_POST['func'] == 2) { $dbca = taskdb(); $dbca->set_charset("utf8"); $mobileUser = $_POST['phone']; $fullnameUser = $_POST['fullname']; $usernameUser = $_POST['

我正在尝试向我的SQL数据库发送一个INSERT查询,但它不起作用,并且没有出现错误,但是如果我从phpMyAdmin发送查询,它会起作用。 以下是我的PHP代码:

if ($_POST['func'] == 2) {
$dbca = taskdb();
$dbca->set_charset("utf8");
$mobileUser = $_POST['phone'];
$fullnameUser = $_POST['fullname'];
$usernameUser = $_POST['username'];
$sql = "INSERT INTO users (UserPhone, Username, UserFullname) VALUES (?,?,?)";
$result = $dbca->prepare($sql);
$result->bind_param("sss", $mobileUser,$fullnameUser,$usernameUser);
echo json_encode(array('profileUser' => 'DONE'));
}
下面是我的java(客户端)代码,它位于AsyncT doInBacground中:

HttpClient httpclient = new DefaultHttpClient();
  HttpPost httppost = new HttpPost("http://192.168.2.26/MyProject/fetchData.php");
  try {
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("func", "2"));
    nameValuePairs.add(new BasicNameValuePair("phone", Login.user_phone));
    nameValuePairs.add(new BasicNameValuePair("fullname", fullname.getText().toString()));
    nameValuePairs.add(new BasicNameValuePair("username", username.getText().toString()));
    Log.e("mainToPost", "mainToPost" + nameValuePairs.toString());
    UrlEncodedFormEntity form;
    form = new UrlEncodedFormEntity(nameValuePairs,"UTF-8");
    httppost.setEntity(form);
    HttpResponse response = httpclient.execute(httppost);
    InputStream inputStream = response.getEntity().getContent();
    Signup.InputStreamToStringExample str = new Signup.InputStreamToStringExample();
    responseSignup = str.getStringFromInputStream(inputStream);
    Log.e("response", "response -----" + responseSignup);
    jsonresponse = new JSONObject(responseSignup);
  } catch (Exception e) {
    e.printStackTrace();
  }
  return null;
HttpClient-HttpClient=newdefaulthttpclient();
HttpPost HttpPost=新的HttpPost(“http://192.168.2.26/MyProject/fetchData.php");
试一试{
List nameValuePairs=新的ArrayList();
添加(新的BasicNameValuePair(“func”,“2”));
添加(新的BasicNameValuePair(“电话”,Login.user_phone));
添加(新的BasicNameValuePair(“fullname”,fullname.getText().toString());
添加(新的BasicNameValuePair(“用户名”,username.getText().toString());
Log.e(“mainToPost”、“mainToPost”+nameValuePairs.toString());
UrlEncodedFormEntity表单;
表单=新的UrlEncodedFormEntity(nameValuePairs,“UTF-8”);
httppost.setEntity(表格);
HttpResponse response=httpclient.execute(httppost);
InputStream InputStream=response.getEntity().getContent();
Signup.InputStreamToString示例str=新建Signup.InputStreamToString示例();
responseSignup=str.getStringFromInputStream(inputStream);
Log.e(“响应”、“响应------”+responseSignup);
jsonresponse=新的JSONObject(responseSignup);
}捕获(例外e){
e、 printStackTrace();
}
返回null;
我在客户机中得到“完成”作为响应,但不会将任何行插入到我的数据库中。 任何帮助都将不胜感激。

添加

$result->execute();
之后

在php文件中

非常感谢:)很抱歉问这个问题,我对php只是个新手
$result->bind_param("sss",  $mobileUser,$fullnameUser,$usernameUser);