close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

is there a way to check " if data is inserted " in case of "UNIQUE" field?

Thread began 10/08/2015 6:56 pm by Sing | Last modified 10/12/2015 11:23 am by Ray Borduin | 1170 views | 2 replies |

Sing

is there a way to check " if data is inserted " in case of "UNIQUE" field?

<?php require_once('../Connections/wa_cnx.php'); ?>
<?php require_once('../webassist/mysqli/queryobj.php'); ?>
<?php
if ("" == "") {
$InsertQuery = new WA_MySQLi_Query($wa_cnx);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "list_select";
$InsertQuery->bindColumn("ls_label", "s", "xyz", "WA_DEFAULT");
$InsertQuery->saveInSession("");
$InsertQuery->execute();
$InsertGoTo = "";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>

In the above example (insert on page load .i.e.: before page load) : page gets executed in-dependent of what happens to INSERT query.

there is no possibility to check whether " record is INSERTED" or " NOT "

FOR INSTANCE:
if the field " ls_label " is UNIQUE and same value is already present in the field, 'THIS page simply gets executed " and doesn't give a clue about " DUPLICATE Entry " i.e. " 1062 - Duplicate entry "

In fact if the field already has the same value, it should have been generating " a Duplicate Entry " error????

Can someone please help me? solve this issue ??


Thank you in advance,
Sin

Sign in to reply to this post

Ray BorduinWebAssist

You can use the server behavior "webassist->MySQLi->authentication->check new username"

That can be used to look for duplicate records before the insert takes place and redirect to display an error message.

Sign in to reply to this post
Did this help? Tips are appreciated...

Sing

Thank you Ray, i made it work using your trick.

It would be nice to " echo " an error by default itself, if for some reason insert fails...
Secondly, i was un aware about its silence, and took me a long time to see what was the real issue.

I thank you for your quick response, and hope that WebAssist will take care of this, since this is an important fix.. ( i believe)...

Originally Said By: Ray Borduin
  You can use the server behavior "webassist->MySQLi->authentication->check new username"

That can be used to look for duplicate records before the insert takes place and redirect to display an error message.  
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

Content

rating

Layout

rating

Ease of use

rating

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...