close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Duplicate entry '4' for key 'PRIMARY'

Thread began 7/12/2013 7:31 am by FrankJay | Last modified 7/12/2013 8:48 am by FrankJay | 672 views | 2 replies |

FrankJay

Duplicate entry '4' for key 'PRIMARY'

I have completed the checkout wizard with partial success. I am writing the visitor and cart details to my own simplified database tables, namely: promo and promo details based on the setup of the wa_ecommerce free database.

After writing to the database, I am successfully sending an email to the user and to the site owner.

If I only have one product in my shopping cart and complete the checkout process, I have complete success.

If however, I have more than one product in the shopping cart, I get the following error when testing: Duplicate entry '4' for key 'PRIMARY' but it does email if the cart contains multiple items.

I believe this is in relation to the promo details database table that stores the. promotion details

I have tried fiddling with the bindings to the primary ID key and foreign ID key. As soon as I removed the binding from the primary ID key column, I get an error stating that this field must have an entry. By default in the wizard process this is the value that has been bound:

<?php echo ((isset($_SESSION["ssCartPromo_OrderID"]))?$_SESSION["ssCartPromo_OrderID"]:""); ?>

Is this column not supposed to be an auto incrementing field?

promo table fields:
promoid, promoname, promosurname, promoemail ….

promodetails table fields:
promodetailid, detailpromoid, promodetailcode, promodetailname ...

I do unfortunately not know how or what information to bind to the following key which is the ID of the promotion table.

When testing on my local server, (and returning to the cart page from Dreamweaver) after completing the checkout process, I noticed that the same items are still in the shopping cart. They are not being cleared from the shopping cart. How do I correct this?

Appreciate the help.

Sign in to reply to this post

Jason ByrnesWebAssist

in your database, make sure the promo.promoid and promodetails.promodetailid columns are both set to auto increment.

in the store order summary behavior, set the promo.promoid column as the key column (Sounds like this is already correct). Do not set a binding for the promo.promoid column, leave that unbound.

in the store order details behavior, set the Key Column to the promodetails.detailpromoid and bind thta column to the session created by the store order summary behaivor.

do not bind the promodetailid column to anything, let the database assign the value.

to clear the cart after the order is processed, add the following code to the checkout success page after the closing </body> tag:

php:
<?php

// Initialize the session.
// If you are using session_name("something"), don't forget it now!
@session_start();

// Unset all of the session variables.
$_SESSION = array();

// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
    
$params session_get_cookie_params();
    @
setcookie(session_name(), ''time() - 42000,
        
$params["path"], $params["domain"],
        
$params["secure"], $params["httponly"]
    );
}

// Finally, destroy the session.
@session_destroy();
@
session_regenerate_id();
?>
Sign in to reply to this post

FrankJay

Thanks Jason

All sorted and fully operational.

Quite stoked as I now learned how to set a Key Column in the behavoir.

Much appreciated

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