Reputation:
I am struggling with the following error in my OO PHP code:
Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0
This is my code:
<?php
error_reporting(E_ERROR | E_PARSE);
include_once 'config/database.php';
include_once 'objects/product.php';
// get database connection
$database = new Database();
$db = $database->getConnection();
// prepare product object
$product = new Product($db);
// get id of product to be edited
$data = json_decode(file_get_contents("php://input"));
// set ID property of product to be edited
$product->id = $data->id;
// read the details of product to be edited
$product->readOne();
// create array
$product_arr[] = array(
"id" => $product->id,
"name" => $product->name,
"description" => $product->description,
"price" => $product->price
);
// make it json format
print_r(json_encode($product_arr));
?>
I have tried the updating php.ini file and it does not work...
Upvotes: 2
Views: 8312
Reputation:
sorry thanks you were right :)
$_REQUEST['id']
-> took away the error
// get id of product to be edited
$data = json_decode(file_get_contents("php://input"));
replaced json_decode(file_get_contents("php://input"));
this with this $_REQUEST['id']
Upvotes: 1