![]() |
Can't print values in "view". But I can print them ok in "controller" and "model"! - 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: Can't print values in "view". But I can print them ok in "controller" and "model"! (/showthread.php?tid=55511) |
Can't print values in "view". But I can print them ok in "controller" and "model"! - El Forum - 10-30-2012 [eluser]behnampmdg3[/eluser] Hello; I am sure this is a simple thing. I was wondering why I get this error. Many thanks. Quote:A PHP Error was encounteredController Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Model Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); View Code: <?php print_r($p);?> Please note" Print_r($p) shows correct results in controller and model, but not in view! Can't print values in "view". But I can print them ok in "controller" and "model"! - El Forum - 10-30-2012 [eluser]jmadsen[/eluser] if you look in the system file: system/core/loader at: Code: public function view($view, $vars = array(), $return = FALSE) you'll see that the parameter that passes the data must be an array or object. The most typical way to pass your data would be: Code: $data['p'] = $this->logic_model->show_hotels(); In your view you can then access $p as a variable Can't print values in "view". But I can print them ok in "controller" and "model"! - El Forum - 10-30-2012 [eluser]LuckyFella73[/eluser] Code: // in your controller Look at the manual to get detailed information about that: http://ellislab.com/codeigniter/user-guide/general/views.html Section "Adding Dynamic Data to the View" |