• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Undefined variable: admin_id

#1
Bug 
New to Codeigniter need help




A PHP Error was encountered
Severity: Notice
Message: Undefined variable: admin_id
Filename: admins/admin-profile.php
Line Number: 16
Backtrace:
File: C:\xampp\htdocs\dgos\application\views\admins\admin-profile.php
Line: 16

Function: _error_handler

File: C:\xampp\htdocs\dgos\application\controllers\Admins.php
Line: 47

Function: view

File: C:\xampp\htdocs\dgos\index.php

Line: 315

Function: require_once
Reply

#2
As, the error message says, line 16 in C:\xampp\htdocs\dgos\application\views\admins\admin-profile.php has not been set.
Reply

#3
(01-11-2019, 12:28 AM)ciadmin Wrote: As, the error message says, line 16 in C:\xampp\htdocs\dgos\application\views\admins\admin-profile.php has not been set.
here is the view page I define it please take a  look 
 


 <div class="card-body">
                                    <?php
                                        $profile_info = $this->db->get_where('admin' , array('admin_id' => $admin_id))->result_array();
                                        foreach($profile_info as $row):?>
                                        <div class="mx-auto d-block">
                                            <img class="rounded-circle mx-auto d-block" src="<?php echo base_url().'assets/' ; ?>images/icon/avatar-11.jpeg" alt="Card image cap">

                                            <h5 class="text-sm-center mt-2 mb-1"><?php echo $row['name'];?></h5>
                                            <div class="location text-sm-center">
                                                <i class="fa fa-map-marker"></i> Karachi, Pakistan</div>
                                        </div>
Reply

#4
Yes sir but I define this variable in admin-profile. Should I define that variable again in a controller of this view page or not
Reply

#5
I don't see $admin_id defined there. I see an array, where the key 'admin_id' references some variable $admin_id, which must be defined elsewhere or you will get an undefined variable error message. Hmmmmm.
Reply

#6
For one you should not be running database queries in the view that should be done in the controller.

Then assign the result to the $data array pass it to the view then loop through it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#7
(01-11-2019, 01:48 AM)ciadmin Wrote: I don't see $admin_id defined there. I see an array, where the key 'admin_id' references some variable $admin_id, which must be defined elsewhere or you will get an undefined variable error message. Hmmmmm.

Alright thanks
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.