Welcome Guest, Not a member yet? Register   Sign In
  Accessing a function directly
Posted by: El Forum - 10-22-2008, 10:55 PM - Replies (3)

[eluser]CodeIgniterNoob[/eluser]
I have a function that passes an id to a destination page that pulls data from a table based on that id. Everything works fine when the URL contains a number at the end like post/1, but when I hit the function directly like post/ it gives errors saying "Message: Missing argument 1 for welcome::post()" .

Is there a way to make that URL redirect to another page?


  Search Result and Pagination Error
Posted by: El Forum - 10-22-2008, 10:42 PM - No Replies

[eluser]Unknown[/eluser]
Hi everyone.
I'm quite new to programming and having a hard time doing this application. Ive been reading a lot of the topics here regarding searches and pagination, but i just cant seem to do it right. Can someone please help me? I would really appreciate it! :cheese:

Im doing a search engine displaying the program names. The search function is working but whenever the query reaches the page limit (example 10) and clicked the page 2 button of the pagination link, the items from my database are shown instead of the 2nd page from query result. Also, there's an error that says that theres an Undefined index, which is the $term (search keyword). BTW, Im using MS SQL.


Here's the controller:

Code:
<?php

class Pgmlist extends Controller {
    
    function __construct()
    {
        parent::Controller();
        $this->load->helper('url');     //creates a url link
        $this->load->helper('form');
        $this->load->database();
        $this->load->library('session');
      
    }
    
    function index()
    {
      
                $term = $_POST['term'];
            
                if(isset($_POST['term']))
                {
                 $this->session->set_userdata('term', $term);          
                }

                $this->session->userdata('term');
                $newdata = $this->session->userdata('term');
            
    
                 //load pagination class
                $this->load->library('pagination');
                $config['base_url'] = base_url().'index.php/pgmlist/index/'.$term;
                                            
                $config['total_rows'] = $this->db->count_all('saiyo');
                $config['per_page'] = '10';
                $config['full_tag_open'] = '<p>';
                $config['full_tag_close'] = '</p>';
          
                $this->pagination->initialize($config);
                        

  
                 //load model and get result
                 $this->load->model('search_model');
                 $data['result'] = $this->search_model->get_programs($term,  $config['per_page'], $this->uri->segment(3, 0));
                      
                //load the HTML table class
                 $this->load->library('table');
                 $this->table->set_heading('番組名');
                 $this->load->view('pgmlist_view', $data);  
}//end of controller

?&gt;



Here's the model:

Code:
&lt;?php

class Search_model extends Model{
    
    function search_model()
    {
        parent::Model();
    }//end of search_model function
    

    function get_programs($term, $num, $offset)
    {
    
       $sql = "Select TOP $num * from saiyo
        where programName not in
        (select top $offset programName from saiyo WHERE programName LIKE '%%$term%%' ) and programName
        like '%%$term%%' ";
        
       $Q = $this->db->query($sql);

        if ($Q->num_rows() > 0){
            foreach($Q->result_array() as $row)
            {
                $data[] = $row;            
            }
            $Q->free_result();
            return $data;              
              }

    }//end of search($term)function

    
}
?&gt;


The view:
(the following are only parts of the view)


Code:
&lt;?php
                echo form_open('pgmlist/index');
                
                $data1 = array(
                   'name' => 'term',
                   'id' => 'term',
                   'maxlength' => '50',
                   'size' => '50',
                   'style' => 'background-color:#f1f1f1'
                );
          
                echo form_input($data1);
                echo form_submit('submit', 'search');
                echo form_close();
       ?&gt;
      
    &lt;?php foreach($result as $row): ?&gt;
    <td>
    &lt;?php echo anchor('pgmlist/programs', $row['programName']); ?&gt;
    </td>
    </tr>
    &lt;?php endforeach; ?&gt;
        
    &lt;?php echo $this->pagination->create_links(); ?&gt;


  first segment in uri
Posted by: El Forum - 10-22-2008, 09:19 PM - Replies (1)

[eluser]dbashyal[/eluser]
is it possible to put dash in uri 1st segment

Quote:i.e. inplace of 'aboutus' can it be 'about-us' but load controller 'aboutus' no dash.

if yes, how can i do it?

Thank you.


  IgnitedRecord model functionality: hook, behavior or something else?
Posted by: El Forum - 10-22-2008, 08:49 PM - Replies (3)

[eluser]echadwickb[/eluser]
I'm learning ignited record with a small faq app. The app needs to let the user order the each faq element. In the table I've got an order column. When a user changes or adds an faq, I'd like the model to adjust the order of all the faqs in the table to accomodate re-ordering of the element.

So I'd run an sql statement like this right before the save:

UPDATE faqs SET order = order + 1 WHERE order > $this->order

So should I create a behaviour, hook or do something else? Add_hook looks promising, but the documentation implies the hook function needs to be in the controller. Doesn't seem right to put this functionality in the controller. It really belongs in the model. I'm still researching behaviour.

Thanks to anyone who can give me some direction.


  Simple Question
Posted by: El Forum - 10-22-2008, 08:44 PM - Replies (6)

[eluser]Ryann[/eluser]
i execute an
echo anchor('news/local/123', 'My News');

but the url seems to be
http://localhost/myci/index.php/news/local/123

how can i eliminate the index.php
http://localhost/myci/news/local/123


  Live version of the website is not loading other controllers - keeps showing the default page
Posted by: El Forum - 10-22-2008, 06:46 PM - Replies (11)

[eluser]davetao[/eluser]
Hi Folks,

Having some very strange issues and was wondering if anyone has come across it.

I have a code igniter website that is working fine on my localhost, I can access a controller called feed on my website and it shows a blank page as it should.

I then upload it through FTP to a live linux server and when i go to the feed controller, it shows me the content from the welcome controller.

Any ideas as to why?

I have a feeling that it might have something to do with either my filenames or htaccess.

the htacess file is as follows..

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|js|css|images|robots\.txt|license\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Much appreciated for any help provided


  XML RPC Server - Indexed array problem
Posted by: El Forum - 10-22-2008, 06:22 PM - Replies (6)

[eluser]CarNinja[/eluser]
Hi,

Most people seem to be having problems with associative arrays. I'm having a problem with indexed arrays. No matter what I do, I can't seem to get this to return a valid response.

Here's the bulk of the code. getbyUserId() returns a result() from an active record db query.

Code:
$qryRecords = $this->weight_model->getByUserId( $objUser->user_id, 99999, 0, false );

$arrResponse = array();

foreach( $qryRecords as $objRecord )
{
    array_push( $arrResponse, array( 'intRecordId' => array( $objRecord->record_id, 'int' )));
}

return $this->xmlrpc->send_response( array( array( 'arrWeightRecords' => array( $arrResponse, 'array' )) , 'struct' ));

Any help is greatly appreciated. I've been tooling on this for about 4 hours now with no luck, and I've scoured the boards and the user guide as well.

Thanks!


  Dreamhost Database Error issue
Posted by: El Forum - 10-22-2008, 06:10 PM - Replies (3)

[eluser]freakish777[/eluser]
Hey All,

I'm new to PHP, CodeIgniter, and Dreamhost (professionally I'm an ASP.NET 3.5 developer, but have a friend I'm helping create a website who had already created a DreamHost account, and figured learning php is something I should get around to anyways). In any event, I've set up my database.php file with:

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "myusername";
$db['default']['password'] = "mypassword";
$db['default']['database'] = "myDBname";
$db['default']['dbdriver'] = "mysql";

and I've set up the autoloader.php file with:

$autoload['libraries'] = array('database');

Lastly in the Dreamhost panel I've set up the myusername account with access from the following hosts:

%.dreamhost.com
%
%.%.%.%
%.mywebsite.com
myipaddress


But I still receive the:

"A Database Error Occurred

Unable to connect to your database server using the provided settings."

error message. Is there something I'm overlooking?


  Rapid Development tools
Posted by: El Forum - 10-22-2008, 04:35 PM - Replies (1)

[eluser]codeboy[/eluser]
Hi All,
I am new to CI and am building multiple CRUD forms at the moment. Can you tell me if there are any rapid application development tools for CI that I could use?

Thanks,
CB


  benifit of using to many controllers
Posted by: El Forum - 10-22-2008, 04:34 PM - Replies (1)

[eluser]Programming Life[/eluser]
What is the benifit of using to many controllers?
How many controllers are possible in framework?


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Retaining search variable...
by pchriley
21 minutes ago
SQL server connection not...
by JustJohnQ
30 minutes ago
CVE-2022-40834 SQL Inject...
by reactionstudio
49 minutes ago
How to use Codeigniter wi...
by sr13579
1 hour ago
Disable debug output in v...
by groovebird
1 hour ago
CI 4.5.1 CSRF - The actio...
by kenjis
2 hours ago
CodeIgniter v4.5.0 Releas...
by kenjis
3 hours ago
Cache best practice?
by BhambriRohunu
4 hours ago
Bug with sessions CI 4.5....
by InsiteFX
4 hours ago
Codeigniter Shield Bannin...
by kenjis
9 hours ago

Forum Statistics
» Members: 85,315
» Latest member: virginiawatercar
» Forum threads: 77,578
» Forum posts: 375,991

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB