• 29-09-2023, 18:33:04
    #1
    Merhaba mysql veritabanını yükseltikten sonra böyle bir hata almaya başladım

    149. satır
     if (strtotime($result[$a]->createdAt) > strtotime("-10 min") and in_array($result[$a]->categorySlug, $kat)){

    Hata
    [27-Sep-2023 13:54:09 Europe/Istanbul] PHP Warning:  Trying to access array offset on value of type null in /home/--/public_html/cron2.php on line 149
    [27-Sep-2023 13:54:09 Europe/Istanbul] PHP Warning:  Attempt to read property "createdAt" on null in /home/--/public_html/cron2.php on line 149
  • 29-09-2023, 18:40:24
    #2
    $result 'de geçerli olmayan bir öğeye erişiyor ve null değeri döndürüyor muhtemel.
    Önce değeri kontrol edin:

    if (isset($result[$a]) && is_object($result[$a]) && isset($result[$a]->createdAt) && strtotime($result[$a]->createdAt) > strtotime("-10 min") && in_array($result[$a]->categorySlug, $kat)) {
        // Kodunuzu buraya ekleyin
    }
  • 29-09-2023, 18:43:18
    #3
    Arrayle ilişkili değerler boş veya hatalı dönüyor olabilir siz önce o arrayleri print_r ile yazdırın. Ne var ne yok bakın. Sonra koşullarsınız. Ayrıca mysqli_error'u açmak da yardımcı olabilir.