How to prevent duplicate entries in MySQL and PHP?

Let’s learn how to prevent duplicate entries in MySQL and PHP. The most accurate or helpful solution is served by Stack Overflow.

There are ten answers to this question.

Best solution

php/mysql prevent duplicate entries over multiple columns

I would like to come up with a standard practice to prevent any tables from having duplicates where it matters. In most cases duplicates are a combination of variables rather than one. My primary keys are just the unique ids for each field so I cannot use them. What I have been doing is querying the table first and then if the number of rows for the combination in question is 0, making the insert. However, I have read it should be possible to set up a unique key over multiple fields to enforce uniqueness...

Answer:

You can simply create a multiple-column index on these columns and enforce uniqueness: see the MySQL...

Read more

user1260310 at Stack Overflow Mark as irrelevant Undo

Other solutions

When should one employ MySQL stored procedures?

I have a table with 1.2 million rows. When I query that table for the last 50 entries (order by post_id desc limit 50), I'm also performing 2 left outer joins (to retrieve the value of the poster's screen name and the value of their location name). I...

Answer:

In MySQL, stored procedures don't make queries run faster. But stored procs can be used to avoid network...

Read more

Bill Karwin at Quora Mark as irrelevant Undo

Help me find and resolve a traffic bottleneck at my colo.

Help me find and resolve a traffic bottleneck at my co-location. We launched a new web-app (it registers users and delivers flash content) at my work and the server fell over at about 17 conn/sec. Help me prevent this from happening again. The network...

Answer:

I manage a server doing 3 million dynamic requests per day and have hit problems like this before. Running...

Read more

fishfucker at Ask.Metafilter.Com Mark as irrelevant Undo

What is SAS, does it need a third party database to work, or is SAS itself a database?

If I wanted to develop a tool where people could enter form information into a web based form so that the field data was imported into a SAS system, what SAS products would I need to do this? Also, I would want to check the field data, say for first...

Answer:

SAS is Statistics Analytics Software../ From traditional statistical analysis of variance and predictive...

Read more

cuteboy at Yahoo! Answers Mark as irrelevant Undo

MySQL: Remove similar (not necessarily exact duplicate) entries from table?

I need to remove similar entries in a table. e.g. if there is a table of street names with x, y coordinates, then I want to remove street names that are the same name AND within close proximity. If we define 'close proximity' to be "((x2-x1)^2 ...

Answer:

Assume a column named, "id", which uniquely identifies each row, and also happens to ascend...

Read more

hippo at Yahoo! Answers Mark as irrelevant Undo

How to prevent multiple voting? (PHP & MySQL)?

I basically have a voting system for games. I'm building an ecommerce website and am inputting a feature to allow users to vote on games good or bad. Now I have PHP knowing if ...show more

Answer:

They can change their IP yes or it can automatically change. You can simple use session data as a means...

Read more

72ZHNOAXFHARYSLVWSTSKBSZGU at Yahoo! Answers Mark as irrelevant Undo

PHP and MySql...Updating Multiple Records

I am working on a web page in PHP and MySql. I've been using Dreamweaver MX 2004. The web page lists a user's properties using the "repeat region" behavior. Beside every property, there is a checkbox with the value of the user's property (name...

Answer:

Hello flyguylol-ga, Thank-you for your question. It is difficult to reproduce your webpage locally...

Read more

flyguylol-ga at Google Answers Mark as irrelevant Undo

In mysql 5.1.40, what's the error "You can't use locks with log tables" on mysql.general_log & mysql.slow_log?

I have mysql 5.1.40 on my linux webserver. Running mysqlcheck there are 2 errors in the mysql database: mysql.general_log Error : You can't use locks with log tables. status : OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK mysql...

Answer:

Running table checks implicitly locks the table (equivelant to executing 'LOCK TABLES') to prevent concurrency...

Read more

Tocci at Yahoo! Answers Mark as irrelevant Undo

Please help me connecting to mysql database using php.?

Hi guys, I have designed a very simple guestbook using a mysql database and php to link to my website but am having problems getting it going. Am fairly new to this kind of programming so I am sure its something simple ..... Basically ..... I have a...

Answer:

The code should work (I believe) so perhaps you have the wrong name of the database? I would suggest...

Read more

Yiaggi at Yahoo! Answers Mark as irrelevant Undo

MySQL and PHP suggestions for beginner?

I am looking for suggestions for inexpensive online or real life courses, books, or web sites that will help a friend learn MySQL and PHP. Hello, I have a friend in Dudley, UK who would like to get ino database development, MySQL in particular. He also...

Answer:

The "Building Dynamic Websites" course from the Harvard Extension School might be helpful...

Read more

parrot_person at Ask.Metafilter.Com Mark as irrelevant Undo

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.