gpt4 book ai didi

php - 尝试更新表中的图像但未执行更新

转载 作者:行者123 更新时间:2023-11-28 23:59:54 24 4
gpt4 key购买 nike

i am trying to updata image in register table by default i allowed null there.

当用户登录时,他/她可以上传他们的照片,这会导致注册表更新,但这里只更新不执行是我的 php 代码,php 页面的数据来自 Asynktask 类。更新后我发送 json resonse android application.register 表包含名称为 user_image 的图像字段

   $email=$_POST['email'];
$name = $_POST['name'];
$phone= $_POST['mobile'];
$userimage = mysql_real_escape_string($_POST['image']);
// include db connect class
require_once __DIR__ . '/db_connect.php';
$db = new DB_CONNECT();

$q="UPDATE register SET name ='$name',
user_image ='$userimage',
phone_number = '$phone' WHERE register.email ='$email'";// check if row inserted or not
if ($result) {
// successfully inserted into database
$response["success"] = 1;
$response["message"] = "User Info successfully Updated.";

// echoing JSON response
echo json_encode($response);
} else {
// failed to insert row
$response["success"] = 0;
$response["message"] = "Oops! An error occurred.";

// echoing JSON response
echo json_encode($response);
}
?>

这是我的 Asynkask 类,我从中将带有图像的数据发送到上面提到的 php 页面类 UpdateInfo 扩展 AsyncTask {

    @Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(Myinfo.this);
pDialog.setMessage("Updating Please Wait..");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}

protected String doInBackground(String... args) {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("email", email_id));
params.add(new BasicNameValuePair("name", uname));
params.add(new BasicNameValuePair("mobile", umobile));
params.add(new BasicNameValuePair("image",setImageString));
JSONObject json = jsonParser.makeHttpRequest(url_update_info,
"POST", params);

// check log cat fro response
Log.d("Create Response", json.toString());

// check for success tag
try {
int success = json.getInt(TAG_SUCCESS);


} catch (JSONException e) {
e.printStackTrace();
}

return null;
}

/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog once done
pDialog.dismiss();
}

}

最佳答案

 I think you must have to use  follwing update query try it and let me know 

$email=$_POST['email'];
$name = $_POST['name'];
$phone= $_POST['mobile'];
$buffer=$_POST['image'];
$user_image = base64_decode($buffer);
// $userimage = mysql_real_escape_string($userimage2);
// include db connect class
require_once __DIR__ . '/db_connect.php';
$db = new DB_CONNECT();
$q=sprintf("UPDATE register SET
name='%s',user_image='%s',phone_number='%s' WHERE email='%s'",
$name, mysql_real_escape_string($user_image), $phone, $email);
$result = mysql_query($q);

关于php - 尝试更新表中的图像但未执行更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30273394/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com