CodeIgniter Forums
Undefined variable - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Undefined variable (/showthread.php?tid=56046)



Undefined variable - El Forum - 11-22-2012

[eluser]Shaser[/eluser]
Some body can tell me what I doing wrong?

Controller

Code:
function providerCombox(){
        
        $myData = array();
        
        $data = $this->mod_Provider->showProvider();
        $dataArray = array('rs_articulos'=>$data);
                
        $this->load->view('Product/new_product',$dataArray);
      
    }

View

Code:
$myData = array();
      foreach ($dataArray as $row){
            
         $myData[] = $row;
                
      }
      $viewData = json_encode($myData);

page error

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: dataArray
Filename: Product/new_product.php
Line Number: 4

Thank you


Undefined variable - El Forum - 11-22-2012

[eluser]Sanjay Sarvaiya[/eluser]
you have done wrong.
your foreach loop will be.
Code:
foreach($rs_articulos as $row) {



Undefined variable - El Forum - 11-22-2012

[eluser]Shaser[/eluser]
I do it but a have the same error Sad I don't know what happen


Undefined variable - El Forum - 11-23-2012

[eluser]Sanjay Sarvaiya[/eluser]
its ridiculous, make sure that you change on new_product.php file.


Undefined variable - El Forum - 11-23-2012

[eluser]Shaser[/eluser]
It's solve thank you