Well, the error must show more than just this right?
Trying to access array offset on value of type null
i was working on laravel 5.7 and i upgrade to laravel 5.8 . in 5.7 it was working fine without error. but in 5.8 i get this error.
ErrorException
Trying to access array offset on value of type null
yes ,i already install 7.4 how can i use 7.3
Can you show code that caused the error, maybe some of us wants to check our 7.4 install to see if we also get the error. It will help narrow it down. Also as @bobbybouwmann mentioned, more of the error.
I use array's often in php and I have php 7.4, but no array problems yet.
ignition error page
Illuminate\Foundation\Bootstrap\HandleExceptions::handleError :42
app/Http/Controllers/LinksController.php:42
my code
use Debugbar;
use Theme;
use MetaTag;
use Request;
class LinksController extends HomeController
{
public function index(){
$isuser = user_logged_in();
$user = User::where('id', $isuser->id)->where('status', 1)->first();
$totalLinks = UserLinks::where('user_id', $isuser->id)->count();
$qlinks = array();
$lnks = UserLinks::where('user_id', $isuser->id)->orderBy('id', 'DESC')->get();
foreach($lnks as $link){
$post = Posts::where('id', $link->post_id)->first();
$category = Categories::where('id', $post['category'])->first();
$qlinks[$link->id] = $link;
$qlinks[$link->id]['post_title'] = $post['title'];
$qlinks[$link->id]['post_image'] = $post['image'];
$qlinks[$link->id]['post_link'] = $post['link'];
$qlinks[$link->id]['post_category'] = $category['name'];
$qlinks[$link->id]['post_category_slug'] = $category['slug'];
$qlinks[$link->id]['post_tagline'] = $post['tagline'];
}
Have you used the browser developer tools to see what's going on, also dd at a couple of places as needed to ensure you are getting expected results.
Also check your variables: https://wiki.php.net/rfc/notice-for-non-valid-array-container
Edit: I tested this https://laracasts.com/discuss/channels/guides/paginate-collection-simple-example-guide bottom example with some null values, no problem. I think (not sure however) you are getting a null key.
Which one is line 42?
try
$qlinks[$link->id] = $link;
$qlinks[$link->id] = array(); // extra line to initialise sub-array
$qlinks[$link->id]['post_title'] = $post['title'];
had the same issue for 2 days now. Phew! tried to switch php versions 7.4 to 7.3 from local to inside vm still no luck
this solved it for me https://stackoverflow.com/a/60379764
Running the composer update command in solved this issue for me: composer update
Thanks sir, this really help me!
@claudios have you found a solution?
I facing this issue on "trying to access array offset on value of type null" on {{ $product['category']['category_name'] }} {{ $product['subcategory']['subcategory_name'] }} {{ $product->product_name }} @extends('frontend.master_dashboard')
@section('main')
<div class="container">
<div class="breadcrumb">
<a href="index.html" rel="nofollow"><i class="fi-rs-home mr-5"></i>Home</a>
<span></span> <a href="shop-grid-right.html">{{ $product['category']['category_name'] }}</a> <span></span> {{ $product['subcategory']['subcategory_name'] }} <span></span>{{ $product->product_name }}
</div>
</div>
</div>
<div class="container mb-30">
<div class="row">
<div class="col-xl-10 col-lg-12 m-auto">
<div class="row mb-50 mt-30">
<div class="col-md-6 col-sm-12 col-xs-12 mb-md-0 mb-sm-5">
<div class="detail-gallery">
<span class="zoom-icon"><i class="fi-rs-search"></i></span>
<!-- MAIN SLIDES -->
<div class="product-image-slider">
@foreach($multiImage as $img)
<figure class="border-radius-10">
<img src="{{ asset($img->photo_name) }} " alt="product image" />
</figure>
@endforeach
</div>
<!-- THUMBNAILS -->
<div class="slider-nav-thumbnails">
@foreach($multiImage as $img)
Please or to participate in this conversation.