嗨,我的PHP更新查詢不會返回任何值。它應該返回我success
或failed
但它不是你們能解決這個問題嗎?PHP Mysql更新查詢不會返回任何內容
無視證券在這裏我只是使用這個查詢爲我的android應用程序。
這是我的代碼。
<?php
include_once("connection.php");
if(isset($_POST['txtCar_No']) && isset($_POST['txtCarModel']) &&
isset($_POST['txtCarType']) && isset($_POST['txtCapacity']) &&
isset($_POST['image']) && isset($_POST['txtFuelType']) &&
isset($_POST['txtPlateNumber']) && isset($_POST['txtcarPrice']))
{
$now = DateTime::createFromFormat('U.u', microtime(true));
$id = $now->format('YmdHis');
$upload_folder = "upload";
$path = "$upload_folder/$id.jpeg";
$fullpath = "http://carkila.esy.es/$path";
$image = $_POST['image'];
$Car_No = $_POST['txtCar_No'];
$Car_Model = $_POST['txtCarModel'];
$Car_Type = $_POST['txtCarType'];
$Capacity = $_POST['txtCapacity'];
$Fuel_Type = $_POST['txtFuelType'];
$PlateNumber = $_POST['txtPlateNumber'];
$carPrice = $_POST['carPrice'];
$query = "UPDATE tbl_cars SET Car_Model='$Car_Model', Car_Type='$Car_Type', Capacity='$Capacity', fuelType='$Fuel_Type' ,carPlatenuNumber='$PlateNumber', image='$fullpath' , carPrice = '$carPrice' WHERE Car_No=$Car_No";
$result = mysqli_query($conn,$query);
echo $Car_No;
if($result > 0){
echo "success";
exit();
} else {
echo "failed";
exit();
}
}
?>
請檢查[this](http://stackoverflow.com/questions/6131304/how-to-determine-if-a-mysql-update-query-succeeded-when-the-data-passed-in-the -q)問題。由於其相關並在 – Taacoo
之前處理,您可以使用mysqli_error函數並在查詢中檢查錯誤。它顯示查詢 – bhawani
中的任何錯誤使用mysqli_num_rows($ result) – phpdroid