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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:53:42+00:00 2026-05-23T16:53:42+00:00

I am using UNIQUE Constraint in my table for two columns to prevent duplicate

  • 0

I am using UNIQUE Constraint in my table for two columns to prevent duplicate rows. If I try to insert a row with the same 2 columns I get

A Database Error Occurred Error
Number: 1062

Duplicate entry ’62-88′ for key
‘subscription’

INSERT INTO subscriptions
(user_id, subscribed_to, date)
VALUES (’62’, ’88’, ‘2011-07-11
19:15:13’)

Filename:
C:\wamp\www\mysite\system\database\DB_driver.php

Line Number: 330

How can I return a php error, e..g Already subscribed! instead of displaying the 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-05-23T16:53:42+00:00Added an answer on May 23, 2026 at 4:53 pm

    Call mysql_errno() after your mysql_query() and check for 1062.

    Note: It’s a more common/intuitive solution to query the database first. See answer by Manocho.

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

Sidebar

Related Questions

I am using an oracle table and have created a unique constraint over four
I need to search across multiple columns from two tables in my database using
I'm using ormlite for Android and I'm trying to get a multiple column unique-constraint.
I have rows in an Oracle database table which should be unique for a
Im using xsd:unique in an xsd generated code. How do I get an item
There are two ways to create a constraint, Method A: ALTER TABLE dbo.<tablename> ADD
I'm using SQL Server 2008. I have a database table that looks like this
Firstly, by using Primary key am I applying the UNIQUE constraint properly? <?php //
I want to make a table that simply has two integer columns to serve
ALTER TABLE admins ADD CONSTRAINT uc_EmailandDeleted_at UNIQUE (email,deleted_at); I have changed my table to

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.