Welcome Guest, Not a member yet? Register   Sign In
Active Record (Set) Browser issue?

I am currently building a site that will capture page views and store them in a database. My code seems very straight-forward but the results are questionable...

When using Firefox 3.6.18 and Google Chrome 12.0.742.112 I end up with (2) page views added to the database rather than (1). In IE 8.0.7600.16385 it only increases the page views by (1), which is correct.

I can't figure out what the difference is but logging in/out doesn't change the results. I'm pretty new to CodeIgniter as well as MVC-logic in general so my debugging abilities are pretty limited.

Here's my Controller:

public function content()
            $this->db->where('title', $this->uri->segment(3));
            $this->db->select('photo_uploads.title as title, photo_uploads.file_name as file_name, titles.title_id as title_id, titles.title_name as title_name, titles.description as description');
            $this->db->join('titles', 'photo_uploads.title = titles.title_id');

            $this->data->query = $this->db->get('photo_uploads');
            $this->data->content = 'hub/title_view';
            $this->load->view('layouts/standard_layout', $this->data);



Here's the Model:

public function add_view() {

        $this->db->where('page_name', uri_string());
        $pages = $this->db->get('pages');

        if(!$pages->num_rows() > 0) {
            $db_info = array (
                'page_name'     =>      uri_string(),
                'views'         =>      '1'

            $this->db->insert('pages', $db_info);
        else {

        $this->db->set('views', 'views+1', FALSE);
        $this->db->where('page_name', uri_string());
        $this->db->update('pages') ;

And the View:

<div id="content_area">
    <div class="top_ads">
        <div class="internal_ad"><a href="#"><img src="&lt;?= base_url();?&gt;images/internal_ad.png"></a></div>
        <div class="banner_ad"><img src="&lt;?= base_url();?&gt;images/banner_ad.jpg"></div>
    <div class="category_head">
    <div class="right_ad">
    <img src="&lt;?= base_url();?&gt;images/right_ad.jpg" />
    &lt;?php foreach($query->result() as $row):?&gt;
    <div class="image_results">
        <img >file_name;?&gt;" height="333px" />
    &lt;?php endforeach;?&gt;

To reiterate the problem:

Chrome and FF both add (2) page views to my database when the page is loaded. IE only adds (1) page view. I have no clue why...

Any help would be appreciated.

Theme © iAndrew 2016 - Forum software by © MyBB