Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Fatal Error


mustdoit

Recommended Posts

Hi,

 

I'm getting a fatal error when trying to access admin. I just installed gift voucher and every thing went ok, followed directions to the letter, except for the error message saying I can't redeclare create_coupon_code. I know it's probably something simple but for the life of me I don't know what I need to do. The error reads as follows:

 

Fatal error: Cannot redeclare create_coupon_code() (previously declared in /home/xxxxxxxx/public_html/admin/includes/functions/general.php:18) in /home/pricsan3/public_html/admin/includes/add_ccgvdc_application_top.php on line 25

 

I am fairly new so any help would be appreciated!

Link to comment
Share on other sites

You need to remove the create_coupon_code() function declaration in /home/xxxxxxxx/public_html/admin/includes/functions/general.php

"Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein

Link to comment
Share on other sites

You need to remove the create_coupon_code() function declaration in /home/xxxxxxxx/public_html/admin/includes/functions/general.php

 

What part of it - the whole thing or part. Here is the code for /home/xxxxxxxx/public_html/admin/includes/functions/general.php

 

// ########### Added CCGV ####################

 

////

// Create a Coupon Code. length may be between 1 and 16 Characters

// $salt needs some thought.

 

function create_coupon_code($salt="secret", $length=SECURITY_CODE_LENGTH) {

$ccid = md5(uniqid("","salt"));

$ccid .= md5(uniqid("","salt"));

$ccid .= md5(uniqid("","salt"));

$ccid .= md5(uniqid("","salt"));

srand((double)microtime()*1000000); // seed the random number generator

$random_start = @rand(0, (128-$length));

$good_result = 0;

while ($good_result == 0) {

$id1=substr($ccid, $random_start,$length);

$query = tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_code = '" . $id1 . "'");

if (tep_db_num_rows($query) == 0) $good_result = 1;

}

return $id1;

}

////

 

Thanks,

 

Terry

Link to comment
Share on other sites

What part of it - the whole thing or part. Here is the code for  /home/xxxxxxxx/public_html/admin/includes/functions/general.php

 

// ########### Added CCGV ####################

 

////

// Create a Coupon Code. length may be between 1 and 16 Characters

// $salt needs some thought.

 

  function create_coupon_code($salt="secret", $length=SECURITY_CODE_LENGTH) {

    $ccid = md5(uniqid("","salt"));

    $ccid .= md5(uniqid("","salt"));

    $ccid .= md5(uniqid("","salt"));

    $ccid .= md5(uniqid("","salt"));

    srand((double)microtime()*1000000); // seed the random number generator

    $random_start = @rand(0, (128-$length));

    $good_result = 0;

    while ($good_result == 0) {

      $id1=substr($ccid, $random_start,$length);       

      $query = tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_code = '" . $id1 . "'");   

      if (tep_db_num_rows($query) == 0) $good_result = 1;

    }

    return $id1;

  }

////

 

Thanks,

 

Terry

 

Sorry, I did not include all of the code for gift voucher section. It is as follows:

 

// ########### Added CCGV ####################

 

////

// Create a Coupon Code. length may be between 1 and 16 Characters

// $salt needs some thought.

 

function create_coupon_code($salt="secret", $length=SECURITY_CODE_LENGTH) {

$ccid = md5(uniqid("","salt"));

$ccid .= md5(uniqid("","salt"));

$ccid .= md5(uniqid("","salt"));

$ccid .= md5(uniqid("","salt"));

srand((double)microtime()*1000000); // seed the random number generator

$random_start = @rand(0, (128-$length));

$good_result = 0;

while ($good_result == 0) {

$id1=substr($ccid, $random_start,$length);

$query = tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_code = '" . $id1 . "'");

if (tep_db_num_rows($query) == 0) $good_result = 1;

}

return $id1;

}

////

// Update the Customers GV account

function tep_gv_account_update($customer_id, $gv_id) {

$customer_gv_query = tep_db_query("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . $customer_id . "'");

$coupon_gv_query = tep_db_query("select coupon_amount from " . TABLE_COUPONS . " where coupon_id = '" . $gv_id . "'");

$coupon_gv = tep_db_fetch_array($coupon_gv_query);

if (tep_db_num_rows($customer_gv_query) > 0) {

$customer_gv = tep_db_fetch_array($customer_gv_query);

$new_gv_amount = $customer_gv['amount'] + $coupon_gv['coupon_amount'];

$gv_query = tep_db_query("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . $new_gv_amount . "' where customer_id = '" . $customer_id . "'");

} else {

$gv_query = tep_db_query("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . $customer_id . "', '" . $coupon_gv['coupon_amount'] . "')");

}

}

////

// Output a day/month/year dropdown selector

function tep_draw_date_selector($prefix, $date='') {

$month_array = array();

$month_array[1] =_JANUARY;

$month_array[2] =_FEBRUARY;

$month_array[3] =_MARCH;

$month_array[4] =_APRIL;

$month_array[5] =_MAY;

$month_array[6] =_JUNE;

$month_array[7] =_JULY;

$month_array[8] =_AUGUST;

$month_array[9] =_SEPTEMBER;

$month_array[10] =_OCTOBER;

$month_array[11] =_NOVEMBER;

$month_array[12] =_DECEMBER;

$usedate = getdate($date);

$day = $usedate['mday'];

$month = $usedate['mon'];

$year = $usedate['year'];

$date_selector = '<select name="'. $prefix .'_day">';

for ($i=1;$i<32;$i++){

$date_selector .= '<option value="' . $i . '"';

if ($i==$day) $date_selector .= 'selected';

$date_selector .= '>' . $i . '</option>';

}

$date_selector .= '</select>';

$date_selector .= '<select name="'. $prefix .'_month">';

for ($i=1;$i<13;$i++){

$date_selector .= '<option value="' . $i . '"';

if ($i==$month) $date_selector .= 'selected';

$date_selector .= '>' . $month_array[$i] . '</option>';

}

$date_selector .= '</select>';

$date_selector .= '<select name="'. $prefix .'_year">';

for ($i=2001;$i<2019;$i++){

$date_selector .= '<option value="' . $i . '"';

if ($i==$year) $date_selector .= 'selected';

$date_selector .= '>' . $i . '</option>';

}

$date_selector .= '</select>';

return $date_selector;

}

// ########### End Added CCGV ####################

 

// #################### Added B2B suite ############

Link to comment
Share on other sites

You need to remove the create_coupon_code() function declaration in /home/xxxxxxxx/public_html/admin/includes/functions/general.php

 

 

I originally posted this yesterday and still have not come up with a solution. :'( Daemonj had a solution, I believe was the answer that made sense but I am a little leary about where to start and end the removal of the code he sugested to remove. Can anyone shed some light on this as I'm so close to having my store live and I want this to be right. Thanks so much for all sugestions as they are appreciated.

 

Here is the code again for reference:

 

// ########### Added CCGV ####################

 

////

// Create a Coupon Code. length may be between 1 and 16 Characters

// $salt needs some thought.

 

function create_coupon_code($salt="secret", $length=SECURITY_CODE_LENGTH) {

$ccid = md5(uniqid("","salt"));

$ccid .= md5(uniqid("","salt"));

$ccid .= md5(uniqid("","salt"));

$ccid .= md5(uniqid("","salt"));

srand((double)microtime()*1000000); // seed the random number generator

$random_start = @rand(0, (128-$length));

$good_result = 0;

while ($good_result == 0) {

$id1=substr($ccid, $random_start,$length);

$query = tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_code = '" . $id1 . "'");

if (tep_db_num_rows($query) == 0) $good_result = 1;

}

return $id1;

}

////

// Update the Customers GV account

function tep_gv_account_update($customer_id, $gv_id) {

$customer_gv_query = tep_db_query("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . $customer_id . "'");

$coupon_gv_query = tep_db_query("select coupon_amount from " . TABLE_COUPONS . " where coupon_id = '" . $gv_id . "'");

$coupon_gv = tep_db_fetch_array($coupon_gv_query);

if (tep_db_num_rows($customer_gv_query) > 0) {

$customer_gv = tep_db_fetch_array($customer_gv_query);

$new_gv_amount = $customer_gv['amount'] + $coupon_gv['coupon_amount'];

$gv_query = tep_db_query("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . $new_gv_amount . "' where customer_id = '" . $customer_id . "'");

} else {

$gv_query = tep_db_query("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . $customer_id . "', '" . $coupon_gv['coupon_amount'] . "')");

}

}

////

// Output a day/month/year dropdown selector

function tep_draw_date_selector($prefix, $date='') {

$month_array = array();

$month_array[1] =_JANUARY;

$month_array[2] =_FEBRUARY;

$month_array[3] =_MARCH;

$month_array[4] =_APRIL;

$month_array[5] =_MAY;

$month_array[6] =_JUNE;

$month_array[7] =_JULY;

$month_array[8] =_AUGUST;

$month_array[9] =_SEPTEMBER;

$month_array[10] =_OCTOBER;

$month_array[11] =_NOVEMBER;

$month_array[12] =_DECEMBER;

$usedate = getdate($date);

$day = $usedate['mday'];

$month = $usedate['mon'];

$year = $usedate['year'];

$date_selector = '<select name="'. $prefix .'_day">';

for ($i=1;$i<32;$i++){

$date_selector .= '<option value="' . $i . '"';

if ($i==$day) $date_selector .= 'selected';

$date_selector .= '>' . $i . '</option>';

}

$date_selector .= '</select>';

$date_selector .= '<select name="'. $prefix .'_month">';

for ($i=1;$i<13;$i++){

$date_selector .= '<option value="' . $i . '"';

if ($i==$month) $date_selector .= 'selected';

$date_selector .= '>' . $month_array[$i] . '</option>';

}

$date_selector .= '</select>';

$date_selector .= '<select name="'. $prefix .'_year">';

for ($i=2001;$i<2019;$i++){

$date_selector .= '<option value="' . $i . '"';

if ($i==$year) $date_selector .= 'selected';

$date_selector .= '>' . $i . '</option>';

}

$date_selector .= '</select>';

return $date_selector;

}

// ########### End Added CCGV ####################

 

// #################### Added B2B suite ############

 

Thanks,

 

Terry

Link to comment
Share on other sites

You need to remove the create_coupon_code() function declaration in /home/xxxxxxxx/public_html/admin/includes/functions/general.php

 

I have resolved this issue. I just removed all mention of the code from Added CCGV to End Added CCGV and all works as it should with no errors. Thanks for the tip Daemoni.

 

Terry

:thumbsup:

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...