Welcome Guest, Not a member yet? Register   Sign In
ErrorException Trying to access array offset on value of type null
#1
Bug 

I just upgraded XAMPP and PHP version 7.49 and opened a project under development getting an error "ErrorException

Trying to access array offset on value of type null" but previously there was no such error. Can anyone solve the problem?
Reply
#2

Can you show the code lines where the error is??
Reply
#3

(09-09-2020, 03:57 PM)Omar Crespo Wrote: Can you show the code lines where the error is??
Code :

public function getAccess {
$
queryMenu = $this->getIdMenu($menu);

        $id_menu = $queryMenu['id_user_menu'];
}
Reply
#4

(This post was last modified: 09-10-2020, 12:38 PM by Omar Crespo.)

You just missed the parameter, the correct function should be:

public function getAccess($menu)
{
$queryMenu = $this->getIdMenu($menu);
$id_menu = $queryMenu['id_user_menu'];
}

Also check 1 more thing:

Be sure that you are returning a valid value from getIdMenu($menu) function. For this sake, you have exceptions or a more simple way, a condition. Something like this:

public function getIdMenu($menu){

Here goes the code before this part

$variable = this->db->get();

$result = $variable->row_array();

if(!empty($result['id_user_menu']))

return $result;

return FALSE;

}
Reply
#5

Hi,
I am getting the same Error as below, while receiving the Json API Response;
"title": "ErrorException",
    "type": "ErrorException",
    "code": 500,
    "message": "Trying to access array offset on value of type null",


And the Controller code is as below;

<?php

namespace App\Controllers;

use CodeIgniter\Controller;

class Rupiso_callback extends BaseController
{

    public function __construct(){
     
    }


public function index(){

$cryptedText = file_get_contents('php://input');
$responce = json_decode($cryptedText, true);

$type = $responce['type'];
$field1 = $responce['field1'];

if($type == "COLLOCTION"){
$agent_id = substr($field1, 4, 15);
} else{
$agent_id = substr($field1, 4, 15);
}

$tnxid = $responce['tnxid'];
$amount = $responce['amount'];
$payer_via = $responce['field2'];

$rupiso_log = [
'agent_id' => $agent_id,
'tnxid' => $tnxid,
'responce' => $cryptedText
];


$rupisoModel = new \App\Models\RupisoModel();
        $query = $rupisoModel->insert($rupiso_log);

}


}


?>


Please help to clear the issue..
Reply




Theme © iAndrew 2016 - Forum software by © MyBB