Creating Default Object From Empty Value

[size="2"]hi everyone,

i am facing this error

Creating default object from empty value

i have database table named medical_chart in this structure is like [sql]id | details[/sql]

in details column, i am try[size="2"][/size] to store data in object format (json_encode format)

like this one

medical_test": {

        "mt32fc10254023": {

            "name": "ADENOSINE DEAMINASE ; ADA",

            "instructions": "wwwwww"


        "mt32fc10253105": {

            "id": "mt32fc10253105",

            "name": "ABSOLUTE EOSINOPHIL COUNT; AEC",

            "instructions": "sss"


        "mt32fc10268ee8": {

            "name": "CULTURE, AEROBIC, EAR SWAB",

            "instructions": "asasasasasa"


        "mt32fc102533eb": {

            "name": "ABSOLUTE NEUTROPHIL COUNT",

            "instructions": "sasas"



my code is

$chart = MedicalCharts::model()->findByPk($chartid);

        if ($chart === null)

            throw new CHttpException(404, 'The requested page does not exist.');

        $chartDetails = json_decode($chart->details);


       $chartDetails->medical_test->$testId = new stdClass();

                    $chartDetails->medical_test->$testId = array(

                        'name' => $testmodel->name,

                        'instructions' => $testmodel->instructions


                    $chart->details                      = json_encode($chartDetails);

                    $chart->updated_ip                   = $_SERVER['REMOTE_ADDR'];


but it gives me error on this line


Creating default object from empty value. i have try this solution by creating stdClass(). but its not helpful for me.

please help.

thanking you .



remove $ from $testId