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 8131305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:03:36+00:00 2026-06-06T09:03:36+00:00

I am working on a app in CI, I have a model that inserts

  • 0

I am working on a app in CI, I have a model that inserts the image paths from an upload form into the database.

This code works 100% correct in my localhost environment, but when running it on the remote server it fails with

Error Number: 1062

Duplicate entry '89-ci/flatfee/uploads/37' for key 'PRIMARY'

The idea is to use an image_map_table that maps a listingid to an image_path, so the listingid has to be repeated several times over in the table for each image path, hence the duplicate entry. Below is the function in the model:

function insert_paths($params, $transID){

    $lid = $this->getListingID($transID);

    if($lid != false) {
        $i = 0;
        foreach ($params['image_paths'] as $value) {
            $sql = "INSERT INTO listing_image_map(idlisting, image_path) VALUES(".$lid.", '".$value."')";
            $q = $this->db->query($sql);    
            $i++;
        }
        if(sizeof($params['image_paths']) == $i ){
            return true;
        }
    } else {
        return false;
    }
}

$params is an array, passed in from the controller, of all the image paths from the upload form. I understand the error, and why it is happening at a basic level, but a more detailed explanation as to why this works on localhost and not on remote server would be nice, and a possible resolution as well.

Thanks.

EDIT : I found the problem thanks to Ashwini Dhekane. The file paths are created from an array, so the default file path on the server is longer in its structure then on my local environment, so the indices used to create the folder structure had to be increased for the remote server and decreased in the local environment (so right now I have two sets of that code that I keep commenting and un-commenting depending on which server I am working in, bit of a hassle, but I only have to work on this part for a few more days.)

Thanks Ashwini, your post made me look in the right area, so I’ll mark it as correct.

  • 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-06-06T09:03:38+00:00Added an answer on June 6, 2026 at 9:03 am

    '89-ci/flatfee/uploads/37' seems to be the path of the upload file and error shows that the path is the primary key column. You cannot have any two rows having same value in the primary key column.

    If you are trying to upload a SQL dump, then you cannot do it; the keys will always collide. In this case you will have to write a customized script.

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

Sidebar

Related Questions

I am working on an android app and have to use remote database for
I'm working on an app (Written in C#) that have a setting to run
I used to have a small chat app(which was almost working), that uses PHP,
I have a model in App Engine that I am exporting in CSV format
I'm working on unit tests for my Rails app and have run into the
Hello i'm working on a blog app and I have a model: class Post(models.Model):
I am trying to create form that contains another model in rails. I have
We have already built a rails app that has several users and an image
I have an MVC app that I have been working on but I seem
So, I've been working on an app that has a Plan model with a

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.