2

Hi guys i have problem with my code, i have while loop sometimes it gives me error even i did not change anything with code

there is my controller and while loop

public function vehicalshow($id, $city_id){
    $view_id = $id;
    $vehicle=DB::table('tbl_vehicles')->where('id','=',$view_id)->get()->first();
    $owner = DB::table('customers')->where('id', '=', $vehicle->owner_id)->get()->first();
    $v_number = DB::table('transport_numbers')->where('vehicle_id', '=', $view_id)->get()->first();
    $v_type = DB::table('tbl_vehicle_types')->where('id', '=', $vehicle->vehicletype_id)->get()->first();
    $v_brand = DB::table('tbl_vehicle_brands')->where('id', '=', $vehicle->vehiclebrand_id)->get()->first();
    $v_working = DB::table('vehicle_works_fors')->where('id', '=', $vehicle->working_for_id)->get()->first();
    $v_factory = DB::table('vehicle_factories')->where('id', '=', $vehicle->factory_id)->get()->first();
    $v_city = DB::table('tbl_cities')->where('id', '=', $owner->city_id)->get()->first();
    $v_region = DB::table('tbl_states')->where('id', '=', $v_city->state_id)->get()->first();
    $v_registration = DB::table('vehicle_registrations')->where('vehicle_id', '=', $view_id)->get()->toArray();
    $v_inspection = DB::table('vehicle_inspections')->where('vehicle_id', '=', $view_id)->get()->toArray();
    $v_prohibition = DB::table('vehicle_prohibitions')->where('vehicle_id', '=', $view_id)->get()->toArray();
    $v_numbers = DB::table('transport_numbers')->where('vehicle_id', '=', $view_id)->get()->toArray();
    if($vehicle->type == 'vehicle')
    {
        $v_certificate = DB::table('technical_passports')->where('vehicle_id', '=', $view_id)->get()->toArray();
     }else{
        $v_certificate = DB::table('vehicle_certificates')->where('vehicle_id', '=', $view_id)->get()->toArray();
     }
     return view('vehicle.view', compact('vehicle','owner','view_id', 'v_type', 'v_brand', 'v_number', 'v_factory', 'v_working', 'v_city', 'v_region', 'v_registration', 'v_inspection', 'v_prohibition', 'v_certificate', 'v_numbers'));

    }




@while(!empty($v_registration) || !empty($v_inspection) || !empty($v_prohibition) || !empty($v_certificate) || !empty($v_numbers))
                        <?php 
                                $actiontype = '';
                                $actiontime = 0;

                                $vR = null;
                                $vI = null;
                                $vP = null;
                                $vC = null;
                                $vN = null;

                                if(!empty($v_registration[0])){

                                    $actionTime=strtotime($v_registration[0]->date);

                                    $actionType='v_reg';

                                }
                                if(!empty($v_inspection[0])){

                                    $actionTime=strtotime($v_inspection[0]->date);

                                    $actionType='v_reg';

                                }
                                if(!empty($v_prohibition[0])){

                                    $actionTime=strtotime($v_prohibition[0]->date);

                                    $actionType='v_reg';

                                }
                                if(!empty($v_certificate[0])){

                                    $actionTime=strtotime($v_certificate[0]->date);

                                    $actionType='v_reg';

                                }
                                if(!empty($v_numbers[0])){

                                    $actionTime=strtotime($v_numbers[0]->given_date);

                                    $actionType='v_reg';

                                }
                        ?>
                    @endwhile

I am going to sort 5 array according to their date and it is working fine but when i delete some rows from my database then this code gives me error i did not change any code

3 Answers3

0

Please increase "memory_limit" in php.ini file. After update restart xampp/wampp server. You can set memory_limit 256M, 512M.

This will help to you

Harsh Panchal
  • 308
  • 1
  • 8
0

You can increase your memory limit with a specific size with:

ini_set('memory_limit', '3072M');

Or unlimited with

ini_set('memory_limit', '-1');
Arnaud B
  • 90
  • 5
0

Add these two lines if your error belongs to memory limit:

ini_set("memory_limit", "-1"); set_time_limit(0);

Sachin
  • 397
  • 4
  • 13