close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues


check unique entry on update

Thread began 6/07/2011 6:33 pm by Base5 Designs | Last modified 6/08/2011 5:41 am by Base5 Designs | 601 views | 1 replies |

Base5 Designs

check unique entry on update

hi there,

have managed to get the check unique entry on insert working fine by using a recordset and checking if there is an existing value and validating against the recordcount.

now my problem is with the update, obviously as there exists a record (the one i am updating)
it returns 1 as the record count so wont validate.

so how do i check this on an update?

Sign in to reply to this post

Base5 Designs

I managed to sort this out.

for anyone else looking for an anser i did the following.

I followed the same technique as checking on insert, creating a recordset filtered by the new value i wanted to insert and using the server validations to check if the recordset was empty.

the teqnique for update is the same, although as well as filtering the table to insert into by the value you want to insert also add to the where clause the following:

AND myColulmnID != myID

(mycolulmnID is the unique key for the record and myID should be set to $_POST["WADAUpdateRecordID"])

this way we check all records for the new value, except the current record we arew trying to update.

the full recordset code would look something like this:

$colname_slugcheck = "-1";
if (isset($_POST['slug_dct'])) {
$colname_slugcheck = (get_magic_quotes_gpc()) ? $_POST['slug_dct'] : addslashes($_POST['slug_dct']);
$myid_slugcheck = "-1";
if (isset($_POST["WADAUpdateRecordID"])) {
$myid_slugcheck = (get_magic_quotes_gpc()) ? $_POST["WADAUpdateRecordID"] : addslashes($_POST["WADAUpdateRecordID"]);
mysql_select_db($database_albionwines, $albionwines);
$query_slugcheck = sprintf("SELECT id_dct, slug_dct FROM drinkcats_dct WHERE slug_dct = %s and id_dct != %s", GetSQLValueString($colname_slugcheck, "text"),GetSQLValueString($myid_slugcheck, "int"));
$slugcheck = mysql_query($query_slugcheck, $albionwines) or die(mysql_error());
$row_slugcheck = mysql_fetch_assoc($slugcheck);
$totalRows_slugcheck = mysql_num_rows($slugcheck);?>

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...