Welcome Guest, Not a member yet? Register   Sign In
Error Number: 1064 when URL add " - "
#1

[eluser]johanriyan[/eluser]
Hello Guys,

I have error like this :

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2, 2' at line 4

SELECT * FROM (`user`) ORDER BY `no` ASC LIMIT -2, 2

Filename: D:\xampp\htdocs\cibootstrap\system\database\DB_driver.php

Line Number: 330


this error appear when i am add " - " in the pagination.

please help me.

Regards.
Web Developer
#2

[eluser]PravinS[/eluser]
as u are passing "-" in pagination, it is affecting you MySQL query, the query offset values is assigned as "-2" (please check your query)
#3

[eluser]johanriyan[/eluser]
dear Pravins,

thks for reply.

this is my model :

Code:
<?php

class User_model extends CI_Model{

    function get_all($num, $offset)
    {
        
        $this->db->order_by('no', 'ASC');
        $data=$this->db->get('user', $num, $offset);
        return $data->result();
    }
    
    function save($data){
        
        $this->db->insert('user',$data);
    }
}


and this is my controller :

Code:
public function about($id=NULL){

//pengaturan pagination
$jml = $this->db->get('user');

$config['base_url'] = base_url().'index.php/bootstrap/about';
$config['total_rows'] = $jml->num_rows();
$config['per_page'] = '2';
$config['first_page'] = 'Awal';
$config['last_page'] = 'Akhir';
$config['next_page'] = '«';
$config['prev_page'] = '»';





//inisialisasi config
$this->pagination->initialize($config);
      

       //buat pagination
$data['halaman'] = $this->pagination->create_links();
      
    

       //tamplikan data
    $data['query'] = $this->user_model->get_all($config['per_page'], $id);
$this->load->view('include/header');
$this->load->view('about',$data);
$this->load->view('include/footer');


}


how to fix it.
thks.




Theme © iAndrew 2016 - Forum software by © MyBB