View Single Post
Old 02-21-2013, 12:54 PM   PM User | #1
bemore
New Coder

 
Join Date: Feb 2013
Posts: 39
Thanks: 14
Thanked 0 Times in 0 Posts
bemore is an unknown quantity at this point
Question Duplicate entry avoidance on INSERT

I'm working on a game compatibility database. Here is the submission form.
http://oplinfo.hj.cx/insert.php

I'd like to avoid duplicate entries into the database. Here is my INSERT INTO.
Code:
$sql="INSERT INTO $tbl_name(gamename, gamecode, region, mode, vmc, smb, hdd, usb, notes, comp)VALUES('$gamename', '$gamecode', '$region', '$mode', '$vmc', '$smb', '$hdd', '$usb', '$notes', '$comp')";
When a user makes a submission, the gamecode they submit is already unique (because all manufactured games use a unique game code) and relative only to that entry.

So, if user A submits a game to the database that has the gamecode "ABCD-12345", and user B comes along and tries to supply the same gamecode for their entry, I'd like that submit to fail.

Any tip appreciated!
bemore is offline   Reply With Quote