Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help with Discount Coupon Codes 1.4


mschwarz

Recommended Posts

Posted

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

Posted
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

Posted
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?

Posted
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

Posted
jasonabc,

 

What is the proper syntax to add that column?

 

Thanks,

~Mark

 

Never mind, it is already there (see below)sqlpic.jpg

Posted

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

Posted
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?

Posted

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.

Posted
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:

error.jpg

 

here is the error screen:

error1.jpg

 

I used the wrong tags when I posted the error (as code).

 

Thanks,

~Mark

Posted

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;

Posted

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 ('" .

Posted

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...