Search in This Blog

Message: Undefined variable: 0 in CodeIgniter PHP

Problem:

Sometime while working with CodeIngiter / PHP you may encounter "Undefined variable: 0" error.
It surprise to that is "0" (Zero) could be a variable!

Solution:

This "Undefined variable: 0" error come when you use double dollar sign in variable. so remove one dollar ($) sign from variable and error will gone.

Example:

See the below code, specially in red color, it having $$ sign:

$data = array( 'u_login' => $row->u_login,
                        'user_type_id' => $user_type_id,
'user_id'=>$row->user_id,
'transporter_id'=>$transporter_id,
'limit_cr'=>$limit_cr,
'u_c_date'=>$row->u_c_date,
'total_trucks'=>$total_trucks,
'total_liter'=>$total_liter,
'pump_id'=> $$pump_id
                        );

jut remove one $ sign.
Previous
Next Post »