orange 2008-8-26 11:15
新手求助,连接数据库问题。
我刚刚开始学习,在这上面下载的分页的例子,总是报错。
Fatal error: Call to undefined function: base_url() in e:\pagination\system\application\controllers\books.php on line 15
程序如下:
<?php
class Books extends Controller {
function __construct() {
parent::Controller();
$this->load->helper('url');
$this->load->database();
}
function index() {
//load pagination class
$this->load->library('pagination');
$config['base_url'] = base_url().'index.php/books/index/';
$config['total_rows'] = $this->db->count_all('christian_books');
$config['per_page'] = '5';
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$this->pagination->initialize($config);
//load the model and get results
$this->load->model('books_model');
$data['results'] = $this->books_model->get_books($config['per_page'],$this->uri->segment(3));
// load the HTML Table Class
$this->load->library('table');
$this->table->set_heading('ID', 'Title', 'Author', 'Description');
// load the view
$this->load->view('books_view', $data);
}
}
?>
config.php中是这样写的:
$config['base_url'] = "http://127.0.0.1/";
我访问的路径是:
[url]http://127.0.0.1/index.php/books/index/10[/url]
能告诉我什么原因么?急急急
orange 2008-8-26 11:24
另外还有config.php里面的这个代码$config['base_url'] = "[url=http://127.0.0.1/]http://127.0.0.1/[/url]";
与在浏览器中输入的网址有关系么?
Hex 2008-8-26 11:47
装载 url helper!!!!!!!!!!!!
看手册!
Hex 2008-8-26 11:48
$config['base_url'] 是一定要修改的配置,设置成你真实的 URL。
Hex 2008-8-26 13:36
[url]http://codeigniter.org.cn/user_guide/general/helpers.html[/url]