CodeIgniter Forums
can't even get thru tutorial without errors - 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 even get thru tutorial without errors (/showthread.php?tid=37622)

Pages: 1 2 3 4


can't even get thru tutorial without errors - El Forum - 01-15-2011

[eluser]terionm[/eluser]
I'm new to this and working thru tutorials , and I keep getting this error:

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\auto\system\application\controllers\users.php:33)

Filename: codeigniter/Common.php

Line Number: 360

what am I doing wrong I'm about to pull my hair out...


can't even get thru tutorial without errors - El Forum - 01-15-2011

[eluser]InsiteFX[/eluser]
Remove the trailing ?> and make sure there is no whitespace before the <?php tag.

InsiteFX


can't even get thru tutorial without errors - El Forum - 01-15-2011

[eluser]terionm[/eluser]
still nothing: here is the full error I'm getting:

load->model('Users'); } function index(){ // store data for being displayed on view file $data['users']=$this->Users->getUsers(); $data['numusers']=$this->Users->getNumUsers(); $data['title']='Displaying user data'; $data['header']='User List'; // load 'users_view' view $this->load->view('users_view',$data); } }
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\auto\system\application\controllers\users.php:33)

Filename: codeigniter/Common.php

Line Number: 360


404 Page Not Found

The page you requested was not found.


I did everything exactly as the tutorial said named all the files just like the tutorial etc...


can't even get thru tutorial without errors - El Forum - 01-15-2011

[eluser]Cristian Gilè[/eluser]
Please, post the entire controller class and indent and highlight your code using bbcode in the formatting bar.


Cristian Gilè


can't even get thru tutorial without errors - El Forum - 01-15-2011

[eluser]terionm[/eluser]
Code:
class Users extends Controller{

function Users (){

// load controller parent

parent::Controller();

// load 'Users' model

$this->load->model('Users');

}

function index(){

// store data for being displayed on view file

  $data['users']=$this->Users->getUsers();

  $data['numusers']=$this->Users->getNumUsers();

  $data['title']='Displaying user data';

  $data['header']='User List';

// load 'users_view' view

  $this->load->view('users_view',$data);

}

}

I got this tutorial from devshed
http://www.devshed.com/c/a/PHP/Building-a-DatabaseDriven-Application-with-the-Code-Igniter-PHP-Framework/2/


can't even get thru tutorial without errors - El Forum - 01-15-2011

[eluser]Cristian Gilè[/eluser]
I don't see any error. This is a stupid question, I know, but, have you put <?php before the class statement?

Code:
<?php
class Users extends Controller{


Cristian Gilè


can't even get thru tutorial without errors - El Forum - 01-15-2011

[eluser]terionm[/eluser]
yes and no, I put it in, and I've taken it ...put it back...etc...which is right?


can't even get thru tutorial without errors - El Forum - 01-15-2011

[eluser]Cristian Gilè[/eluser]
Remove only the closing tag. The right code is:

Code:
<?php
class Users extends Controller{

function Users (){

// load controller parent

parent::Controller();

// load 'Users' model

$this->load->model('Users');

}

function index(){

// store data for being displayed on view file

  $data['users']=$this->Users->getUsers();

  $data['numusers']=$this->Users->getNumUsers();

  $data['title']='Displaying user data';

  $data['header']='User List';

// load 'users_view' view

  $this->load->view('users_view',$data);

}

}

As InsiteFX said before, make sure there is no whitespace before the <?php opening tag.


Cristian Gilè


can't even get thru tutorial without errors - El Forum - 01-15-2011

[eluser]terionm[/eluser]
not sure if this is right or means anything I named my files:

controller file: users.php

model: users_model.php

view: users_view.php

I thought that was the correct naming convention....


can't even get thru tutorial without errors - El Forum - 01-15-2011

[eluser]terionm[/eluser]
so I renamed the model to just users.php and now I get this error...this db table only has two records in it like the tutorial ...

load->database(); } function getAllUsers(){ $query=$this->db->get('users'); if($query->num_rows()>0){ // return result set as an associative array return $query->result_array(); } } function getUsersWhere($field,$param){ $this->db->where($field,$param); $query=$this->db->get('users'); // return result set as an associative array return $query->result_array(); } // get total number of users function getNumUsers(){ return $this->db->count_all('users'); } }
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 261904 bytes) in C:\xampp\htdocs\auto\system\codeigniter\Common.php on line 75