Reputation: 66
my php is returning null when values are passed to it i checked it with chrome's plugin POSTMAN... i am unable to figure out the problem :\ This is my code i am trying to update the database by sending values from my android code(which is okay):-
<?php
$response = array();
// check for required fields
if (isset($_POST['id']) && isset($_POST['company']) && isset($_POST['date']) &&
isset($_POST['time']) && isset($_POST['ten']) && isset($_POST['twelve']) &&
isset($_POST['aggregate']) && isset($_POST['backlog']) && isset($_POST['pending']) &&
isset($_POST['branch'])) {
$cid = $_POST['id'];
$company = $_POST['company'];
$date = $_POST['date'];
$time = $_POST['time'];
$ten = $_POST['ten'];
$twelve = $_POST['twelve'];
$aggregate = $_POST['aggregate'];
$backlog = $_POST['backlog'];
$pending = $_POST['pending'];
$branch = $_POST['branch'];
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
// mysql update row with matched pid
$result = mysql_query("UPDATE companies SET company = '$company', date = '$date', time
= '$time' ten = '$ten', twelve = '$twelve',aggregate = '$aggregate', backlog =
'$backlog', pending = '$pending', branch = '$branch' WHERE id = $cid");
// check if row inserted or not
if ($result) {
// successfully updated
$response["success"] = 1;
$response["message"] = "Company successfully updated.";
// echoing JSON response
echo json_encode($response);
} else {
}
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
?>
Upvotes: 1
Views: 87
Reputation: 10489
You missed a comma:
= '$time', ten = '$ten', twelve = '$twelve', aggregate = '$aggregate', backlog =
____^_____
Upvotes: 3