Part of the EllisLab Network
   
 
Pagination ‘s bug
Posted: 29 June 2009 01:13 AM   [ Ignore ]  
Summer Student
Total Posts:  6
Joined  06-28-2009
$CI =& get_instance();
        
        if (
$CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
        
{
            
if ($CI->input->get($this->query_string_segment) != 0)
            
{
                $this
->cur_page = $CI->input->get($this->query_string_segment);
                
                
// Prep the current page - no funny business!
                
$this->cur_page = (int) $this->cur_page;
            
}
        }
        
else
        
{
            
if ($CI->uri->segment($this->uri_segment) != 0)
            
{
                $this
->cur_page = $CI->uri->segment($this->uri_segment);
                
                
// Prep the current page - no funny business!
                
$this->cur_page = (int) $this->cur_page;
            
}
        }

        $this
->num_links = (int)$this->num_links;
        
        if (
$this->num_links < 1)
        
{
            show_error
('Your number of links must be a positive number.');
        
}
                
        
if ( ! is_numeric($this->cur_page))
        
{
            $this
->cur_page = 0;
        
}

is_numeric(1.)//return true

if you enter http://locahost/blog/somefunction/1.

it will return some error message

Profile
 
 
Posted: 29 June 2009 09:46 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  202
Joined  12-31-2007

And that error message is…....

Profile
 
 
Posted: 29 June 2009 07:56 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  6
Joined  06-28-2009

It’s about sql

Profile
 
 
Posted: 29 June 2009 08:17 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  6
Joined  06-28-2009

see :http://www.windy020.com/index.php/life/index/0/11.

it will return :

A Database Error Occurred
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 ‘11., 11’ at line 4

SELECT * FROM (`life`) ORDER BY `time` desc LIMIT 11., 11

Profile
 
 
Posted: 29 June 2009 10:50 PM   [ Ignore ]   [ # 4 ]  
Lab Technician
RankRankRankRank
Total Posts:  1242
Joined  04-19-2008

Judging from your URL AND/OR your SQL statement, I think there’s a problem with your code.

 Signature 

PinoyTech - Web Development Blog

Profile
 
 
Posted: 30 June 2009 12:47 AM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  6
Joined  06-28-2009

首先 ,我的代码不存在任何问题。

通常情况下,正常显示的URL为:

http://www.windy020.com/index.php/life/index/0/11

那么这个时候$SQL=“SELECT * FROM (`life`) ORDER BY `time` desc LIMIT 11,11 “;

显示很正常 。


但是

如果我在在地址栏这么写 :


http://www.windy020.com/index.php/life/index/0/11.

最后面包含一个 “.”

很明显这个时候SQL出现语法错误!

在分页类中 使用is_numeric来判断 是否为整数 ,但是is_numeric(1.)会返回 true

Profile
 
 
Posted: 30 June 2009 02:05 AM   [ Ignore ]   [ # 6 ]  
Lab Technician
RankRankRankRank
Total Posts:  1242
Joined  04-19-2008

You should probably look into this:

http://codeigniter.com/forums/viewthread/121302/#601031

 Signature 

PinoyTech - Web Development Blog

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120595 Total Logged-in Users: 50
Total Topics: 126636 Total Anonymous Users: 2
Total Replies: 665686 Total Guests: 456
Total Posts: 792322    
Members ( View Memberlist )