Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3288316
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:35:37+00:00 2026-05-17T20:35:37+00:00

I decided that I would like to track the searches that users are making

  • 0

I decided that I would like to track the searches that users are making on my site, so I created a MySQL table called ‘Searches’ with a few simple fields, and a model (class) to facilitate the insertion and management of the saved searches.

The model function that saves the search is:

public function create() {
    $q = $this->db->query("INSERT INTO 
                                `searches` (
                                    `section`,
                                    `keywords`,
                                    `results`,
                                    `location`,
                                    `date`
                                ) VALUES (
                                    %s, 
                                    %s,
                                    %s,
                                    %s,
                                    %s
                                )",
                                $this->section,
                                $this->keywords,
                                $this->results,
                                $this->location,
                                date('Y-m-d G:i:s'));
    $this->id = $this->db->last_insert($q);
}

…and in my controller, when the page is loaded I go:

    /* lets save the search if there is one */
    if(isset($_GET['q'])) {
        $search = $this->load->model('Searches_Single',null);
        $search->set('section','sale');
        $search->set('keywords',$_GET['q']);
        $search->set('results',$grand_total);
        $search->set('location',$this->location->id);
        $search->create();
        unset($search);
    }

What is baffling me is that 1-4 duplicate rows are often being inserted instead of the just 1 that I expect.

There are no loops, no redirecting…just a very simple pageload. Frankly, I believe this happened to me the last time I attempted this.

UPDATE

This does not happen in my local development environment…only in production (scary). Both share the exact same code…could this be a server thing?

UPDATE NUMBER 2
I am finding that this seems to be happening on page opening and closing. AKA – I check the time the page opens, and the script logs a search then…and then I check the time the page finishes loading, and the script seems to be logging a search there as well…

GAHHH

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:35:38+00:00Added an answer on May 17, 2026 at 8:35 pm

    i determined the problem is that google robots that follow a person to the page to determine which google ad to display are triggering the second pageload and therefore creating a mirrored db insertion. sometimes multiple times on a single page load.

    sigh. cmon google.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to track some information on users, but would like to retain it
I would like to display a toast in Android. I decided that it would
I have a largish Mercurial repository that I've decided would be better as several
Ive decided that I really dont like microsoft and their ways. Please could you
I decided to install APC to speed up the site that I work for.
I have a service with some entities that I would like to expose in
Im feeling crazy and I've decided I would really like to write a User-Defined
Today I decided to come up with a program that would be useful for
I have decided that all my WPF pages need to register a routed event.
I've recently decided that I just have to finally learn C/C++, and there is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.