Fatal error: Call to undefined function base_url() in- why this error coming?
use $this->load->helper(‘url’); in autoload.php
use $this->load->helper(‘url’); in autoload.php
css folder will be inside the codeigniter main folder. system application assets -css access path will be as like below
1 2 |
<link href="<?=base_url();?>assets/css/style.css" rel="stylesheet"> <link href="<?php echo base_url('assets/css/style.css'); ?>" rel="stylesheet" type="text/css" /> |
this is because of same name is used for controller and model file ‘project’. change model or controller to some other names it will work enjoy!!
1 2 3 4 5 6 7 8 |
$this->load->library('form_validation'); $this->form_vallidation->set_rules('project_name','Project Name','trim|required|min_lenth[5]|xss_clean'); if($this->form_validation->run() == FALSE) { $this->index(); } |
Why this error is coming in my coding ?
controller file as like below registration.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Registration extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('user'); } function index() { $this->load->view("reg_view.php"); } public function registration() { $this->load->library('form_validation'); $this->form_validation->set_rules('user_name', 'User Name', 'trim|required|min_length[4]|xss_clean'); if($this->form_validation->run() == FALSE) { $this->index(); } else { //database insertion } } } ?> |
view file as below reg_view.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<div id="testme"> <div class="reg"> <div class="my_title">Sign Up</div> <?php echo validation_errors('<p class="error">'); ?> <?php echo form_open("registration/registration"); ?> <p> <label for="user_name">User Name:</label> <input type="text" id="user_name" name="user_name" value="<?php echo set_value('user_name'); ?>" /> </p> <p> <input type="submit" class="greenButton" value="Submit" /> </p> <?php echo form_close(); ?> </div> </div> |
when i click on the submit button nothing happens Solution is below Please Use capital letter for the controllername
1 |
<?php echo form_open("Registration/registration"); ?> |
This error usualy comes becuse of missing model file or invalid model filename.
Database Creation create a database “my_testdb”. use the below query for generationg tables. CREATE TABLE IF NOT EXISTS questionandanswers ( ID int(10) NOT NULL AUTO_INCREMENT, question longtext NOT NULL, answer1 varchar(250) NOT NULL, answer2 varchar(250) NOT NULL, answer3 varchar(250) NOT NULL, answer4 varchar(250) NOT NULL, answer5 varchar(250) NOT NULL, correctanswer varchar(250) NOT NULL, PRIMARY KEY… Read More »
one method:
please add the below line into your controller $this->load->library(‘pagination’);