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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:37:17+00:00 2026-06-03T13:37:17+00:00

I have a unique key set for a mysql database row so not to

  • 0

I have a unique key set for a mysql database row so not to insert duplicate entries on a form submit. That works fine, but if there’s a duplicate entry the page doesn’t load. Instead the user receives the warning: Duplicate entry ''' for key ''

How do I go about turning that error off and loading the page even if there is a duplicate key, while still using the unique key on the row? I tried setting error report to off, but that didn’t work.

mysql_query("INSERT INTO user
(formemail,UserIP,Timestamp,LP) VALUES('$email','$userip',NOW(),'$lp') ") 
or die(mysql_error());
  • 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-03T13:37:18+00:00Added an answer on June 3, 2026 at 1:37 pm

    You need to change your SQL insert to use INSERT … ON DUPLICATE KEY UPDATE Syntax so that the error isn’t generated in the first place.

    Don’t try to hide the symptom, treat the problem.

    Also, I must point out that the mysql library is being deprecated and should not be used for new code, you should, at the least, use mysqli or, preferably PDO. There is a good tutorial on PDO here if you are interested in learning.

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

Sidebar

Related Questions

I have a database table that has a Unique Key constraint defined to avoid
I have an SQL database with a set of tables that have Unique Id's.
I have a sql file that creates a database in mysql: SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
I have table with a unique auto-incremental primary key. Over time, entries may be
I have a table with 3 fields: ID (not unique, not primary key) timestamp
I have a mysql database and some php that allows you to create an
I have a table with some rows, each row has a unique key. When
I'm using a simple form to insert posts to my MySQL database, I want
I have in my MySQL database these two tables: CREATE TABLE IF NOT EXISTS
I'm trying to SELECT, and get a unique result set, from a MySQL database,

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.