mschwarz Posted July 27, 2006 Posted July 27, 2006 I've been wrestling with getting some sort of coupon codes onto my site. I've finally gotten Discount Coupon Codes 1.4 installed and can see the admin panel and the input box at check out. When I enter a new coupon into the admin, I get the following error: 1136 - Column count doesn't match value count at row 1 insert into discount_coupons ( coupons_id, coupons_description, coupons_discount_percent, date_start, date_end, max_use, min_order) values ('VIPDiscount15', 'VIPDiscount15', '.15', "2006-07-26", "2010-12-31", 0, 0, 0) [TEP STOP] Any help would be much appreciated. This is the final step to getting this store running correctly. Even if someone could tell me how to add the fields into the table by using mySQL, I only have one coupon (discount) to load right now. Thank you, ~Mark
mschwarz Posted July 27, 2006 Author Posted July 27, 2006 Maybe I need to make a change to the table? HELP PLEASE!!!
jasonabc Posted July 27, 2006 Posted July 27, 2006 It's trying to insert 8 values into only 7 columns. Did you run the SQL updates on your database that come with this contribution? Jason My Contributions: Paypal Payflow PRO | Rollover Category Images | Authorize.net Invoice Number Fix
mschwarz Posted July 28, 2006 Author Posted July 28, 2006 It's trying to insert 8 values into only 7 columns. Did you run the SQL updates on your database that come with this contribution? Thanks Jasonabc for your response. I think I ran everything, can you tell me how to add the column by hand? Thanks, ~Mark
jasonabc Posted July 28, 2006 Posted July 28, 2006 well check the sql query - did it create that table with the right number of columns? If it did then the INSERT statement is wrong. Jason My Contributions: Paypal Payflow PRO | Rollover Category Images | Authorize.net Invoice Number Fix
mschwarz Posted July 28, 2006 Author Posted July 28, 2006 well check the sql query - did it create that table with the right number of columns? If it did then the INSERT statement is wrong. OK, I went into mysql and there are 8 fields. So there are enough number of fields and the sql query did it's job right. Any other thoughts?
jasonabc Posted July 28, 2006 Posted July 28, 2006 add a number_available column to your SQL query: ( coupons_id, coupons_description, coupons_discount_percent, date_start, date_end, max_use, min_order, number_available) Jason My Contributions: Paypal Payflow PRO | Rollover Category Images | Authorize.net Invoice Number Fix
mschwarz Posted July 28, 2006 Author Posted July 28, 2006 add a number_available column to your SQL query: ( coupons_id, coupons_description, coupons_discount_percent, date_start, date_end, max_use, min_order, number_available) jasonabc, What is the proper syntax to add that column? Thanks, ~Mark
mschwarz Posted July 28, 2006 Author Posted July 28, 2006 jasonabc, What is the proper syntax to add that column? Thanks, ~Mark Never mind, it is already there (see below)
jasonabc Posted July 28, 2006 Posted July 28, 2006 Mark - I said add it to your SQL query - not your database. Your SQL query is trying to insert eight values into seven columns. Add that eighth column into your INSERT statenent and that will fix the problem. Jason My Contributions: Paypal Payflow PRO | Rollover Category Images | Authorize.net Invoice Number Fix
mschwarz Posted July 28, 2006 Author Posted July 28, 2006 The more I think about this, the more it looks like there might be something wrong with my php code someplace. What I think is that it is trying to insert 7 items into 8 fields, not the other way around. Would it throw an error if this wre the case? ~Mark
mschwarz Posted July 28, 2006 Author Posted July 28, 2006 Mark - I said add it to your SQL query - not your database. Your SQL query is trying to insert eight values into seven columns. Add that eighth column into your INSERT statenent and that will fix the problem. Could you explain where this is and how to add it? Should I search my osC directory for that column name?
jasonabc Posted July 28, 2006 Posted July 28, 2006 In this post: http://www.oscommerce.com/forums/index.php?s=&...st&p=904572 You pasted the very SQL statement that needs changing. What is the page where you get that error? It's almost certainly in there. Otherwsie you will have to search for it. In this post: http://www.oscommerce.com/forums/index.php?s=&...st&p=905095 I told you what to change it to. Jason My Contributions: Paypal Payflow PRO | Rollover Category Images | Authorize.net Invoice Number Fix
mschwarz Posted July 29, 2006 Author Posted July 29, 2006 In this post: http://www.oscommerce.com/forums/index.php?s=&...st&p=904572 You pasted the very SQL statement that needs changing. What is the page where you get that error? It's almost certainly in there. Otherwsie you will have to search for it. In this post: http://www.oscommerce.com/forums/index.php?s=&...st&p=905095 I told you what to change it to. jasonabc, This actually isn't the code: http://www.oscommerce.com/forums/index.php?s=&...st&p=904572 It's the error that comes up when I fill out this form: here is the error screen: I used the wrong tags when I posted the error (as code). Thanks, ~Mark
mschwarz Posted July 29, 2006 Author Posted July 29, 2006 OK, I think I have the code that is the offender but I don't know how to fix it: $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : ''); if (tep_not_null($action)) { switch ($action) { case 'insert': tep_db_query($sql = "insert into " . TABLE_DISCOUNT_COUPONS . " ( coupons_id, coupons_description, coupons_discount_percent, date_start, date_end, max_use, min_order) values ('" . ( !empty( $HTTP_POST_VARS["coupons_id"] ) ? tep_db_input( $HTTP_POST_VARS["coupons_id"] ) : createRandomCoupon() ). "', '" . tep_db_input( $HTTP_POST_VARS['coupons_description'] ) . "', '" . tep_db_input( $HTTP_POST_VARS['coupons_discount_percent'] ) ."', " . ( !empty( $HTTP_POST_VARS['date_start'] ) ? '"'.parseDate( $HTTP_POST_VARS['date_start'], DATE_FORMAT_SHORT ).'"' : 'null' ). ", ". ( !empty( $HTTP_POST_VARS['date_end'] ) ? '"'.parseDate( $HTTP_POST_VARS['date_end'], DATE_FORMAT_SHORT ).'"' : 'null' ). ", ". ( !empty( $HTTP_POST_VARS['max_use'] ) ? (int)$HTTP_POST_VARS['max_use'] : 0 ).", ". ( !empty( $HTTP_POST_VARS['min_order'] ) ? $HTTP_POST_VARS['min_order'] : 0 ).", ". ( !empty( $HTTP_POST_VARS['number_available'] ) ? (int)$HTTP_POST_VARS['number_available'] : 0 ).")"); tep_redirect( tep_href_link( FILENAME_DISCOUNT_COUPONS, 'page=' . $HTTP_GET_VARS['page'] ) ); break;
mschwarz Posted July 29, 2006 Author Posted July 29, 2006 I FIXED it myself!!! Here was the problem: tep_db_query($sql = "insert into " . TABLE_DISCOUNT_COUPONS . " ( coupons_id, coupons_description, coupons_discount_percent, date_start, date_end, max_use, min_order, number_available) <- was missing values ('" .
jasonabc Posted July 29, 2006 Posted July 29, 2006 I know it was missing - I told you to insert that column into your SQL query nine posts ago: http://www.oscommerce.com/forums/index.php?s=&...st&p=905095 Glad it's working now. Jason My Contributions: Paypal Payflow PRO | Rollover Category Images | Authorize.net Invoice Number Fix
mschwarz Posted August 1, 2006 Author Posted August 1, 2006 Thanks jasonabc, I think I didn't get it for a bit there! :blush: Now I have another issue: I can add the discount in the admin panel, and a customer can add a coupon at checkout, but the discount isn't being calculated. Any ideas on why this might happen?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.