Answer the question
In order to leave comments, you need to log in
Why does $bd = $row[0] return null while just $row[0] returns data?
Hello. Everything is somehow very illogical ...
The situation is this. Through cUrl, I receive data not from my server and check with the data on my own. If there are changes, then I write these records to my database. If there are no changes, then I get the previous record and display the changes.
$stmt = $pdo->prepare('SELECT * FROM bd ORDER BY id DESC LIMIT 2;');
$stmt->execute();
$row = $stmt->fetchAll();
$data = json_encode($formData);
$ch = curl_init("https://local.server/api/personal/result?data=$data");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Accept: application/json']);
$result = curl_exec($ch);
if (curl_errno($ch)) $curlerror = 'Ошибка в запросе 2:' . curl_error($ch);
curl_close($ch);
$array = json_decode($result); // Декодируем ответ
$f_arr_person = $array->data; // Получаем статус обработки
for ($i = 0, $size2 = count($f_arr_person); $i < $size2; ++$i) {
$f_str_person = implode("|", (array)$f_arr_person[$i]);
}
if ($f_str_person != $row[0]['data']) {
$sql = 'INSERT INTO bd (data) VALUES (:data)';
$query = $pdo -> prepare($sql);
$query -> execute(['data' => $f_str_person]);
$bd_last = $row[0];
} else {
$bd_last = $row[1];
}
$from["qqq"][] = ["Дата"=>$row[0]["Date"]];
$from["qqq"][] = $f_arr_person;
echo json_encode($from);
$from["qqq"][] = "Дата"=>$bd_last["Date"];
$from["qqq"][] = "Дата"=>$row[0]["Date"];
Answer the question
In order to leave comments, you need to log in
it was a stupid mistake. solved
$stmt = $pdo->prepare('SELECT * FROM bd ORDER BY id DESC LIMIT 2 ;');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question