Welcome Guest, Not a member yet? Register   Sign In
  New Codeigniter site problems
Posted by: El Forum - 11-21-2008, 12:39 PM - Replies (13)

[eluser]chicoNERD[/eluser]
hi, i am new to this forum and i new to codeigniter.

i was building a website using codeigniter and everything is working
fine in the local testing server.
However, when i uploaded the site the server the links die.
i can click on any link and it just show the first page.
the link in the address bar change, but the page still the same.

is it something different that must be done before a live website?
i have the htaccess file and everything in the right place.


  Templating
Posted by: El Forum - 11-21-2008, 12:25 PM - Replies (6)

[eluser]CanadianBeef[/eluser]
I'm just curious...something I have not been able to determine reading the docs hitherto is how you templatize an applicaiton so each page follows similar navigation.

How do you handled situations where a login form might displayed on each page until an individual is logged in at which a "My toolbox" might replace it?

Do you use a HTML static template and "inject" the dyanmic body contents into the template using str_replace?

This would apply to both the body content and possible navigation in the case of login FORM's?

If you could point to an article on best practices in this regard I would appreciate it.

Cheers,
CB


  Frustrated - Upload problem!
Posted by: El Forum - 11-21-2008, 11:16 AM - Replies (2)

[eluser]Lazos[/eluser]
I have this code. It was working just fine. I am sure I did not touch anything but when I completed my application something happened. No more uploading...

I am getting this error "The filetype you are attempting to upload is not allowed."

I went to the upload file and I print_r the mimes and the file type I am sending to the upload class is the correct one.

The result of print_r($mime) is:
Array ( [0] => application/x-zip [1] => application/zip [2] => application/x-zip-compressed )

The result of print_r($this->file_type) is:
\"application/x-zip\"

I do not know if is normal to have the \"\" around it...

Somebody PLEASE HELP I WASTED 4 hours for these and still I do not know why suddenly it stopped working Sad.

Check FileType Function of Upload Class

Code:
function is_allowed_filetype()
    {
        if (count($this->allowed_types) == 0 OR ! is_array($this->allowed_types))
        {
            $this->set_error('upload_no_file_types');
            return FALSE;
        }
                
        foreach ($this->allowed_types as $val)
        {
            $mime = $this->mimes_types(strtolower($val));
        
            if (is_array($mime))
            {
                if (in_array($this->file_type, $mime, TRUE))
                {
                    return TRUE;
                }
            }
            else
            {
                if ($mime == $this->file_type)
                {
                    return TRUE;
                }    
            }        
        }
        
        return FALSE;
    }

Import File Controller
Code:
function import() {
        $field_name = 'userfile';
        echo $_FILES[$field_name]['type'];
        $config['upload_path'] = 'D:/websites/dissertation/application/views/templates/';
        $config['max_size'] = '2000';
        $config['allowed_types'] = 'zip';
        $config['overwrite'] = true;
        $this->load->library('upload', $config);
        if (!$this->upload->do_upload($field_name))
        {
            $error = array('error' => $this->upload->display_errors());
            print_r($error);
            if(!empty($error)) {
                redirect('/index.php/admin/thememanager?error=true&errormsg=error_uploading', 'location', 301);    
            }                                
        }    
        else
        {
            $data = $this->upload->data();
        }
        
    }

Form View
Code:
<form id="themeform2" method="post" action="{V_ACTION}" enctype="multipart/form-data">
                <div class="pageoverflow">
                    <p class="pagetext">Upload Theme</p>
                    <p class="pageinput">&lt;input type="file" name="userfile" size="50" maxlength="255" /&gt;&lt;/p>
                </div>
                <div class="pageoverflow">
                    <p class="pagetext">&nbsp;</p>
                    <p class="pageinput">&lt;input name="submit" value="Import" type="submit" /&gt;&lt;/p>
                </div>
            &lt;/form&gt;


  paniation help
Posted by: El Forum - 11-21-2008, 10:52 AM - Replies (1)

[eluser]Programming Life[/eluser]
Please tell me how i use pagination in short paging to get 20 records per page
what i have done is all shown below config , model , controller , n actuall page
all code is below
thanks if any help is replies


pagination.php config file
=======================

Code:
&lt;?php
$config['base_url'] = 'http://localhost/working/CodeIgniter_1.6.3/index.php/Admin/users/';
$config['total_rows'] = '300';
$config['per_page'] = '20';
?&gt;


controller 'Admin' have function
Code:
function users() {
    
        $data['userdata']    = $this->Madmin->getAllUsers();        
          
        $data['usersStatus'] = $this->Madmin->getAllUsersStatus();

        $data['title']='Users Lists';
        $data['heading']='Users List ';
        $this->load->view('admin/users',$data);
    
    }

view name is : users
====================
Code:
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;&lt;?php echo $title;?&gt;&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;?php    $data_ADD = array( 'src'  => 'asset/newobject.gif' ,'title'=>'Add User' , 'border' => '0');?&gt;
&lt;?php    $data1 = array( 'src'  => 'asset/non.gif' ,'title'=>'Delete User' , 'border' => '0');?&gt;
&lt;?php    $data_EDIT = array( 'src'  => 'asset/edit.gif', 'title'=>'Edit User' , 'border' => '0');?&gt;

&lt;?php echo $this->load->view('admin/header'); ?&gt;

&lt;?php echo br().'<hr>'; ?&gt;
&lt;?php
echo anchor('User/register',img($data_ADD).'Add New'); echo br();
echo 'Total registered Users ::&nbsp; '.$this->db->count_all('register');
echo br();


if( empty($userdata) ) { //if no recored found
echo $msg = 'No Recored Found';

}else {
    
$this->table->add_row('<b>ID', '<b>NAME' , '<b>COUNTRY', '<b>EMAIL','<b>Status','<b>Actions');
//$this->table->add_row(  anchor('User/register',img($data_ADD)) );

$num=1;
$statusCount=0;
foreach($userdata as $records) {
        $color = ($num%2==0)? '#00CCCC': '#00CCCC';
echo '<p style=background-color:'.$color.'>';


    $status = ( $usersStatus[$statusCount]=='yes')? 'Active' :'InActive';
    $this->table->add_row( $records['id'] , $records['name'] , $records['country'] , $records['email'] , $status ,anchor('Admin/delete/'.$records['id'].'',img($data1)) , anchor('Admin/editUser/'.$records['id'],img($data_EDIT)) );            
    


echo '</p>';
$num++;
$statusCount++;
}
echo $this->table->generate();

}//if end

echo $this->pagination->create_links();
?&gt;
&lt;/body&gt;
&lt;/html&gt;


And the model i have is this => 'Madmin'
Code:
function getAllUsers() {
        $dbData = array();
          $this->db->select('*');
        $this->db->limit('');
        $query = $this->db->get('register');        
        
        foreach( $query->result_array() as $records ) {
          $dbData[] = $records;
        }
        return $dbData;
    }
    
    function getAllUsersStatus() {
        $dbData = array();
          $this->db->select('status');
        $query = $this->db->get('login');
        
        foreach( $query->result_array() as $records ) {
          $dbData[] = $records;
        }
        return $dbData;
    }


  Active Record escaping of data
Posted by: El Forum - 11-21-2008, 10:34 AM - Replies (2)

[eluser]Unknown[/eluser]
Hello all.

I'm sorry if this is a really daft question:

Using Active Record syntax to work with a MySQL database, looking at the CI docs there's a note under db->update() to say that all data is escaped (I presume by calling mysql_real_escape_string() somewhere along the line).

The same note isn't present under db->insert().

I was just wondering if someone could please clear up for me when Active Record does all the necessary escaping and when I need to do it myself, please?

Better to ask than to make an insecure assumption...

Thanks in advance,
Mark..


  Problem set_flashdata loads home page?
Posted by: El Forum - 11-21-2008, 07:46 AM - No Replies

[eluser]zimco[/eluser]
I've been playing with the CI app Linkster: tearing it apart and putting it back together again to see how it works and there's something i'm not understanding (or broke) with the Delete function.

When i'm logged-in as admin everytime i try to delete an entry in the listings instead of getting the confirm box to do the delete; it actually loads my home page into the pop-up box and never deletes anything because i can't confirm. All the other functions in the listing section: add, edit, show, all work as expected and the confirm works correctly for a logout. Any suggestions on where to look for the problem?

Here's the code for the delete function

Code:
function remove($id)
    {
        confirm('Do you really want to delete this entry?');
        
        $entry = $this->Listings_model->get_entry($id);
        
        // Can only remove your own entries
        if($entry->FK_user_id !== $this->user->id)
        {
            show_error('The entry you are trying to delete does not exist, or it does not belong to you.');
            exit;
        }
                
        $this->Listings_model->delete_entry($id);
        $this->session->set_flashdata('msg', 'Entry Deleted');
        redirect('member/listings');
    }

Here's the code from the confirm_helper
Code:
function confirm($message = 'Are you sure?')
{
    $CI    =& get_instance();
    $segments = $CI->uri->segment_array();

    if( end($segments) != 'yes')
    {
        if ( ! $referrer = $CI->input->server('HTTP_REFERER'))
        {
            // No user agent referrer, use the controller index
            $RTR =& load_class('Router');
            $referrer = $RTR->fetch_directory().$RTR->fetch_class();
        }

        $data['no_href']    = $referrer;
        $data['yes_href']    = implode('/', $segments).'/yes';
        $data['message']    = $message;
        
        echo $CI->template->load('template', 'content/confirmation', $data, TRUE);

        exit;
    }
}

Here's the code for content/confirmation
Code:
<div id="content"> &lt;!-- Begin CONTENT --&gt;
    <div class="boxview">
    
    <h3>&lt;?php echo $message?&gt;</h3>
    
    <p>&lt;?php echo anchor($yes_href, 'Yes'); ?&gt; / &lt;?php echo anchor($no_href, 'No', array('id' => 'confirm_cancel')); ?&gt;</p>
    
    </div>
</div>&lt;!-- End CONTENT --&gt;


  Autoload not working
Posted by: El Forum - 11-21-2008, 07:19 AM - Replies (9)

[eluser]khuram[/eluser]
Hi

I am trying to Autoload a model. Here is the steps I followed.

1. Extracted a fresh copy of CI from zip and put it in my localhost root.
2. set the database connection from database file in config.
3. Made a simple Model called MCategories with the same code as from the user_guide with the function get_last_ten_categories().
4. Put the model name in the autoload.php like $autoload['model'] = array('MCategories');
5. Tried to call this Model in the welcome controller like this,

Code:
print_r($this->MCategories->get_last_ten_entries());
6. But it gives out an error
Quote:Fatal error: Call to a member function on a non-object in ...\system\application\models\mcategories.php on line 10
.
7. The line 10 is $query = $this->db->get('categories', 10);
8. Is there any step I have forgotten that its not recognizing the Database.

Please help.


  Problem with update attachment
Posted by: El Forum - 11-21-2008, 07:13 AM - Replies (2)

[eluser]Erwin Setiawan[/eluser]
I have problem with edit my post with it's attachment. this is my scripts on controller

Code:
function edit_post()
    {
        $data['css'] = $this->css;
        $data['base'] = $this->base;
        $data['title'] = "Admin";
        $data['heading'] = "Edit Post";
        $data['message'] = "";
        $data['upload_error'] = "";
        $query=$this->cr_posts_model->get_by_id($this->uri->segment(4));
        foreach($query as $row):
            $data['post_title'] =$row->title;
            $data['body']  =$row->body;
            $data['status']=$row->status;
            $data['attach']=$row->attachment;
        endforeach;
        
        //form post
        $data['input_title'] = array(
                'name'             => 'title',
                'id'             => 'title',
                'maxlength'        =>     '50',
                'size'            =>     '50',
                'style'           => 'width:50%'
             );
        $data['input_body'] = array(
                'name'            => 'body',
                'id'              => 'body',
                'rows'             => '50',
                'cols'             => '600',
                'style'           => 'width:100%'
             );
        $data['input_attachment'] = array(
              'name'         => 'attachment',
              'id'             => 'attachment',
              'maxlength'    =>     '100',
              'size'        =>     '50',
              'type'        => 'file',
              'style'       => 'width:50%'
             );
        $data['post_status'] = array(
                'publish'          => 'Publish',
                'unpublish'        => 'Unpublish',
         );
        $this->form_validation->set_rules('title', 'Title', 'trim|required');
        $this->form_validation->set_rules('body', 'Body', 'trim|required');
        $this->form_validation->set_rules('attachment', 'Attachment', 'trim');
        
        if ($this->form_validation->run() == FALSE || !$this->upload->do_upload('attachment'))
        {
            $data['upload_error'] = array('error' => $this->upload->display_errors());
            $this->load->view('admin/cr_edit_view', $data);
        }
        else //submit success
        {
            //upload
            //$this->upload->do_upload('attachment');
            $data['details'] = $this->upload->data();
            //end upload
            $post_id = $this->cr_posts_model->get_next_id();
            $this->cr_posts_model->update();
            $query=$this->cr_posts_model->get_by_id($this->uri->segment(4));
            foreach($query as $row):
                $data['post_title'] =$row->title;
                $data['body']  =$row->body;
                $data['status']=$row->status;
                $data['attach']=$row->attachment;
            endforeach;
                
            if($_POST['button']=="Save"){
                $data['message'] = "Your post has been saved . Continue editing or <a >base."public/company_report/full_page/".$this->uri->segment(4)."'>View Now</a> ?";
            }
            $this->load->view('admin/cr_edit_view', $data);    
        }
    }


And in my model

Code:
function update()
    {
        $details = $this->upload->data();
        $query=$this->cr_posts_model->get_attach($this->uri->segment(4));
        foreach($query as $row):
            $attach=$row->attachment;
        endforeach;
        if($details['file_name']!=""){
                unlink($this->config->item('upload').str_replace($this->base."files/","",$attach));
                $data = array(
                'title' => $_POST['title'],
                'body' => $_POST['body'],
                'status' => $_POST['status'],
                'attachment' => $this->base."files/cr_attachments/".$details['file_name'],
                'modified' => date("Y-m-d H:i:s"),
                'modified_by' => $this->session->userdata('user_id')  
                );
        }else{
        $data = array(
            'title' => $_POST['title'],
            'body' => $_POST['body'],
            'status' => $_POST['status'],
            'modified' => date("Y-m-d H:i:s"),
            'modified_by' => $this->session->userdata('user_id')  
            );
        }
        $this->db->update('cr_posts',$data, array('post_id' => $this->uri->segment(4)));
    }
It's working, i can delete my file if i change text field attachment and it's replace with new one. But I have problem with empty text field attachment. I want to by pass empty text field attachment and keep post updated with old attachment, but by default code igniters $this->upload->display_errors() always catch error "You did not select a file to upload."

any solution for this?
thx for help^^


  adding a blog to a CI application?
Posted by: El Forum - 11-21-2008, 06:42 AM - Replies (5)

[eluser]stepper[/eluser]
we have redeveloped our web app into CI and everything is going well so far.. however I'd like to add a blog and don't feel like re-inventing the wheel. are there any quick solutions out there?

from my research I have found the following options.

1 - integrate wordpress and theme it up like the app
2 - use blaze CMS from blaze.haughin.com, and build a template
3 - use a CMS on top of CI which has a blog plugin: http://codeigniter.com/wiki/Webber_blog_module/
4 - build a simple blog ourselves from scratch
5 - wait for EE 2.0 which will work with CI?

any thoughts? I dont want anything flashy - useable admin, posting articles, categorisation, sticky posts, maybe some commenting.

thanks in advance

js


  rename folder
Posted by: El Forum - 11-21-2008, 06:41 AM - Replies (3)

[eluser]tfncruz[/eluser]
I'm trying to rename a folder using the php rename function like this:

Code:
if($autorNome != $this->input->post('nome')) {
    rename(base_url().'imgs/content/'.$autorNome, base_url().'imgs/content/'.$this->input->post('nome'));
    rename(base_url().'docs/'.$autorNome, base_url().'docs/'.$this->input->post('nome'));
}

php returns the following error:
Message: rename() [function.rename]: http wrapper does not support renaming

Is there any other way to rename a folder?

Thanks in advance!


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

Username
  

Password
  





Latest Threads
Best Way to Implement Aff...
by InsiteFX
07-07-2025, 03:06 AM
curl + response body
by michalsn
07-06-2025, 10:14 PM
AssetConnect - a powerful...
by Crenel
07-06-2025, 04:08 PM
twig and view cell
by foxbille
07-05-2025, 01:58 AM
The pipe operator in PHP ...
by InsiteFX
07-04-2025, 04:18 PM
Heads up for users using ...
by FlavioSuar
07-04-2025, 11:33 AM
Table (view class) Row ID
by grimpirate
07-03-2025, 11:22 PM
Happy 4th Everyone
by InsiteFX
07-03-2025, 09:31 PM
AbuseIPDB Module
by InsiteFX
07-03-2025, 09:27 PM
tool bar not showing
by Luiz Marin
07-03-2025, 04:46 AM

Forum Statistics
» Members: 155,737
» Latest member: Volanixedge
» Forum threads: 78,441
» Forum posts: 379,735

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB