CodeIgniter Forums
Unable to access value from controller to view.. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Unable to access value from controller to view.. (/showthread.php?tid=62678)



Unable to access value from controller to view.. - vijjucse - 08-13-2015

Hi,
I am getting an error while accessing data from controller to view.
The $data variable 'ddlcountry' is inaccessible in my view.

following is the error code iam getting.

I am new to codeigniter. please suggest the possible error cause.


Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: ddlcountry

Filename: views/register.php

Line Number: 59

Backtrace:

File: C:\xampp\htdocs\JobPortal\application\views\register.php
Line: 59
Function: _error_handler

File: C:\xampp\htdocs\JobPortal\application\controllers\JS_Register.php
Line: 18
Function: view

File: C:\xampp\htdocs\JobPortal\index.php
Line: 292
Function: require_once



RE: Unable to access value from controller to view.. - Ridd - 08-13-2015

Paste your code from controller and view Wink


RE: Unable to access value from controller to view.. - PaulD - 08-15-2015

I doubt this will enlighten you in any way, but that error is telling you that you have referenced a variable called ddlcountry on line 59 of your register.php view that has not been defined.

I am sure that has been no help at all :-)

Best wishes,

Paul.


RE: Unable to access value from controller to view.. - John_Betong - 08-15-2015

(08-13-2015, 06:25 AM)[email protected] Wrote: To help solve your problem, please supply the following:

1. conroller source code showing how you allocate  $data[ 'ddlcountry' ]
2. controller source code showing how the $data is passed to the view.
3. view source code showing how $ddlcountry is called



RE: Unable to access value from controller to view.. - Wouter60 - 08-16-2015

If your controller has this:
PHP Code:
$data['dllcountry'] = 'Some value';
$this->load->view('myview',$data); 
then your view (in this case 'myview.php') is able to use the value of the variable $dllcountry.
In your view:
PHP Code:
<?php echo $dllcountry;?>
will result in 'Some value'.