I have a problem with pagenition pls help |
[eluser]Fahad Alrahbi[/eluser]
Hello ,all i am using codeigniter with Smarty template engine and when i try to use pagenition it's working but if Url is http://localhost/cic/showq/viewv/8 and i add (') or (-) i got error after add http://localhost/cic/showq/viewv/-8 error msg is Quote:A Database Error Occurred My Code controllers : Code: <?php Template showq.tpl Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
[eluser]skunkbad[/eluser]
The pagination class needs to use a number, not a number with extra chars you feel like adding. Why do you need those extra chars? Maybe re-read the user guide section on pagination; it's really easy to do when you follow the guide.
[eluser]Fahad Alrahbi[/eluser]
Hello , Thanks for reply i want if visitor change the page url he will go to first page not showing db error is my code correct ? im new in codeigniter
[eluser]Ckirk[/eluser]
You could make use of the form validation library to determine whether $this->uri->segment(3) is actually a number. I've changed your code so try the code below. It's untested but should work. I haven't accounted for anyone entering a valid page number, which exceeds the number of records in the database. In this scenario your query would return zero results but I'm sure you know how to handle that - at least there's no DB/SQL errors now Code: <?php
[eluser]johanriyan[/eluser]
thks guys, Code: $page = !$this->form_validation->is_natural($this->uri->segment(3)) ? 0 : $this->uri->segment(3); how to show show_404(); if page not valid.
[eluser]Pert[/eluser]
You can force 404 error, there are some examples on this page http://stackoverflow.com/questions/12367...cing-a-404 You could also help visitor out a little and normalise the values Code: if ($page < 1) This way they will still see meaningful information rather than are forced to 404 page. Lets say there is only one item on the last page that they are trying to access and you delete said item, they will end up on 404 page when in fact it would be more helpful if it just lands on last page available.
[eluser]johanriyan[/eluser]
when i am add (-) in URL, i want show such as image. how to create.
[eluser]Ckirk[/eluser]
[quote author="johanriyan" date="1372131698"]when i am add (-) in URL, i want show such as image. how to create.[/quote] Code: if(!$this->form_validation->is_natural($this->uri->segment(3))) show_error('You are not authorised to perform this action'); |
Welcome Guest, Not a member yet? Register Sign In |