-3
我使用API,並返回我一些數據,我的網址在JSON:我收到錯誤非法串偏移 '的requestId'
這是實際的URL數據:
data={%22requestId%22%3A%22546b384ce51f469a2e8b4567%22%2C%22numbers%22%3A{%22917566559950%22%3A{%22date%22%3A%222014-11-18+17%3A45%3A59%22%2C%22status%22%3A1%2C%22desc%22%3A%22DELIVERED%22}}}
我的PHP代碼是插入數據的數據庫,但得到的錯誤:
$request = $_REQUEST["data"];
$jsonData = json_decode($request,true);
$link = mysqli_connect("127.0.0.1", "root", "", "table");
foreach($jsonData as $key => $value)
{
$requestID = $value['requestId'] ;
$userId = $value['userId'];
$senderId = $value['senderId'];
foreach($value['report'] as $key1 => $value1)
{
//detail description of report
$desc = $value1['desc'];
// status of each number
$status = $value1['status'];
// destination number
$receiver = $value1['number'];
//delivery report time
$date = $value1['date'];
$query = "INSERT Query for store record ";
mysqli_query($link, $query);
}
}
這裏有什麼問題的錯誤 警告:非法串關在線11設置'requestId' 警告:非法字符串偏移'userId'..... 請解決它....
讓我補充: 1)這將有助於你和潛在的受訪者你的問題,如果您的解碼URL編碼的JSON。 2)你得到的錯誤信息是告訴你,你試圖使用'requestID'作爲一個字符串的索引。因此,$值必須是一個字符串。這將是你檢查價值$價值的原因,以及爲什麼。 –