Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Fatal error: Cannot redeclare tep_db_connect()


Procella

Recommended Posts

When clicking on "affiliate Information" on my frontpage (www.drikkegel.dk/catalog/) i get the error:

Fatal error: Cannot redeclare tep_db_connect() (previously declared in /home/drikkege/public_html/catalog/includes/functions/database.php:13) in /home/drikkege/public_html/catalog/includes/functions/database.php on line 25

 

 

Also, when in Admin, adding a banner, i get:

1054 - Unknown column 'affiliate_category_id' in 'field list'

 

insert into affiliate_banners (affiliate_banners_title, affiliate_products_id, affiliate_category_id, affiliate_banners_image, affiliate_banners_group, affiliate_date_added, affiliate_status) values ('banner1', '0', '0', 'banners/', '', now(), '1')

 

[TEP STOP]

 

 

Anyone encountered this?

I did a search on google and oscommerce. Files in language/dansk/ seems to be correct.

Timo Jensen

Link to comment
Share on other sites

When clicking on "affiliate Information" on my frontpage (www.drikkegel.dk/catalog/) i get the error:

Fatal error: Cannot redeclare tep_db_connect() (previously declared in /home/drikkege/public_html/catalog/includes/functions/database.php:13) in /home/drikkege/public_html/catalog/includes/functions/database.php on line 25

Also, when in Admin, adding a banner, i get:

1054 - Unknown column 'affiliate_category_id' in 'field list'

 

insert into affiliate_banners (affiliate_banners_title, affiliate_products_id, affiliate_category_id, affiliate_banners_image, affiliate_banners_group, affiliate_date_added, affiliate_status) values ('banner1', '0', '0', 'banners/', '', now(), '1')

 

[TEP STOP]

Anyone encountered this?

I did a search on google and oscommerce. Files in language/dansk/ seems to be correct.

 

Solved DB problem by running folowing in PHPMyAdmin. Line is from affiliate.sql

 

ALTER TABLE `affiliate_banners` ADD `affiliate_category_id` INT DEFAULT '0' NOT NULL AFTER `affiliate_products_id` ;

Timo Jensen

Link to comment
Share on other sites

When clicking on "affiliate Information" on my frontpage (www.drikkegel.dk/catalog/) i get the error:

Fatal error: Cannot redeclare tep_db_connect() (previously declared in /home/drikkege/public_html/catalog/includes/functions/database.php:13) in /home/drikkege/public_html/catalog/includes/functions/database.php on line 25

 

Anyone encountered this?

I did a search on google and oscommerce. Files in language/dansk/ seems to be correct.

 

 

Sourcecode for file:

<?php
/*
 $Id: affiliate_show_banner.php,v 2.00 2003/10/12

 OSC-Affiliate

 Contribution based on:

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2002 - 2003 osCommerce

 Released under the GNU General Public License
*/

// CHECKIT
// -> optimize code -> double parts

// require of application_top not possible 
// cause then whois online registers it also as visitor
//

 define('TABLE_AFFILIATE_BANNERS_HISTORY', 'affiliate_banners_history');
 define('TABLE_AFFILIATE_BANNERS', 'affiliate_banners');
 define('TABLE_PRODUCTS', 'products');

// Set the local configuration parameters - mainly for developers
 if (file_exists('includes/local/configure.php')) include('includes/local/configure.php');
 require('includes/configure.php');
 if (file_exists('includes/local/affiliate_configure.php')) include('includes/local/affiliate_configure.php');
 require('includes/affiliate_configure.php');

// include the database functions
 require(DIR_WS_FUNCTIONS . 'database.php');
// make a connection to the database... now
 tep_db_connect() or die('Unable to connect to database server!');

 function affiliate_show_banner($pic) {
//Read Pic and send it to browser
$fp = fopen($pic, "rb");
if (!$fp) exit();
// Get Image type
$img_type = substr($pic, strrpos($pic, ".") + 1);
// Get Imagename
$pos = strrpos($pic, "/");
if ($pos) {
  $img_name = substr($pic, strrpos($pic, "/" ) + 1);
} else {
  $img_name=$pic;
}
header ("Content-type: image/$img_type");
header ("Content-Disposition: inline; filename=$img_name");
fpassthru($fp);
// The file is closed when fpassthru() is done reading it (leaving handle useless).  
// fclose ($fp);
exit();
 }

 function affiliate_debug($banner,$sql) {
?>
<table border=1 cellpadding=2 cellspacing=2>
  <tr><td colspan=2>Check the pathes! (catalog/includes/configure.php)</td></tr>
  <tr><td>absolute path to picture:</td><td><?php echo DIR_FS_CATALOG . DIR_WS_IMAGES . $banner; ?></td></tr>
  <tr><td>build with:</td><td>DIR_FS_CATALOG . DIR_WS_IMAGES . $banner</td></tr>
  <tr><td>DIR_FS_CATALOG</td><td><?php echo DIR_FS_CATALOG; ?></td></tr>
  <tr><td>DIR_WS_CATALOG</td><td><?php echo DIR_WS_CATALOG; ?></td></tr>
  <tr><td>DIR_WS_IMAGES</td><td><?php echo DIR_WS_IMAGES; ?></td></tr>
  <tr><td>$banner</td><td><?php echo $banner; ?></td></tr>
  <tr><td>SQL-Query used:</td><td><?php echo $sql; ?></td></tr>
  <tr><th>Try to find error:</td><td> </th></tr>
  <tr><td>SQL-Query:</td><td><?php if ($banner) echo "Got Result"; else echo "No result"; ?></td></tr>
  <tr><td>Locating Pic</td><td>
<?php 
  $pic = DIR_FS_CATALOG . DIR_WS_CATALOG . DIR_WS_IMAGES . $banner;
  echo $pic . "<br>";
  if (!is_file($pic)) {
 echo "failed<br>";
  } else {
 echo "success<br>";
  }
?>
  </td></tr>
</table>
<?php
exit();
 }

// Register needed Post / Get Variables
 if ($HTTP_GET_VARS['ref']) $affiliate_id=$HTTP_GET_VARS['ref'];
 if ($HTTP_POST_VARS['ref']) $affiliate_id=$HTTP_POST_VARS['ref'];

 if ($HTTP_GET_VARS['affiliate_banner_id']) $banner_id = $HTTP_GET_VARS['affiliate_banner_id'];
 if ($HTTP_POST_VARS['affiliate_banner_id']) $banner_id = $HTTP_POST_VARS['affiliate_banner_id'];
 if ($HTTP_GET_VARS['affiliate_pbanner_id']) $prod_banner_id = $HTTP_GET_VARS['affiliate_pbanner_id'];
 if ($HTTP_POST_VARS['affiliate_pbanner_id']) $prod_banner_id = $HTTP_POST_VARS['affiliate_pbanner_id'];

 $banner = '';
 $products_id = '';

 if ($banner_id) {
$sql = "select affiliate_banners_image, affiliate_products_id from " . TABLE_AFFILIATE_BANNERS . " where affiliate_banners_id = '" . $banner_id  . "' and affiliate_status = 1";
$banner_values = tep_db_query($sql);
if ($banner_array = tep_db_fetch_array($banner_values)) {
  $banner = $banner_array['affiliate_banners_image'];
  $products_id = $banner_array['affiliate_products_id']; 
}
 }

 if ($prod_banner_id) {
$banner_id = 1; // Banner ID for these Banners is one
$sql = "select products_image from " . TABLE_PRODUCTS . " where products_id = '" . $prod_banner_id  . "' and products_status = 1";
$banner_values = tep_db_query($sql);
if ($banner_array = tep_db_fetch_array($banner_values)) {
  $banner = $banner_array['products_image'];
  $products_id = $prod_banner_id;
}
 }

// DebugModus
 if (AFFILIATE_SHOW_BANNERS_DEBUG == 'true') affiliate_debug($banner,$sql);

 if ($banner) {
$pic = DIR_FS_CATALOG . DIR_WS_IMAGES . $banner;

// Show Banner only if it exists:
if (is_file($pic)) {
  $today = date('Y-m-d');
// Update stats:
  if ($affiliate_id) {
	$banner_stats_query = tep_db_query("select * from " . TABLE_AFFILIATE_BANNERS_HISTORY . " where affiliate_banners_id = '" . $banner_id  . "' and affiliate_banners_products_id = '" . $products_id ."' and affiliate_banners_affiliate_id = '" . $affiliate_id. "' and affiliate_banners_history_date = '" . $today . "'");
// Banner has been shown today 
	if ($banner_stats_array = tep_db_fetch_array($banner_stats_query)) {
	  tep_db_query("update " . TABLE_AFFILIATE_BANNERS_HISTORY . " set affiliate_banners_shown = affiliate_banners_shown + 1 where affiliate_banners_id = '" . $banner_id  . "' and affiliate_banners_affiliate_id = '" . $affiliate_id. "' and affiliate_banners_products_id = '" . $products_id ."' and affiliate_banners_history_date = '" . $today . "'");
	} else { // First view of Banner today
	  tep_db_query("insert into " . TABLE_AFFILIATE_BANNERS_HISTORY . " (affiliate_banners_id, affiliate_banners_products_id, affiliate_banners_affiliate_id, affiliate_banners_shown, affiliate_banners_history_date) VALUES ('" . $banner_id  . "', '" .  $products_id ."', '" . $affiliate_id. "', '1', '" . $today . "')");
	}
  }
// Show Banner
  affiliate_show_banner($pic);
}
 }

// Show default Banner if none is found
 if (is_file(AFFILIATE_SHOW_BANNERS_DEFAULT_PIC)) {
affiliate_show_banner(AFFILIATE_SHOW_BANNERS_DEFAULT_PIC);
 } else {
echo "<br>"; // Output something to prevent endless loading
 }
 exit();
?>

Timo Jensen

Link to comment
Share on other sites

Timo,

You could try to change this line:

// include the database functions
require(DIR_WS_FUNCTIONS . 'database.php');

to

// include the database functions
require_once(DIR_WS_FUNCTIONS . 'database.php');

That needs to be done also in application_top.php. Probably, the error will go away (it is a problem of loading twice, not allowed).

Link to comment
Share on other sites

Hi Jan

 

I changed both places, but same result.

It only happens when i click "affiliate information" on my front page.

http://drikkegel.dk/catalog/affiliate_info.php

Feel free to try.

 

Maybe some other file? Im not fond of trial and error, so if anyone knows which file to look for errors in...

 

 

Timo,

You could try to change this line:

// include the database functions
require(DIR_WS_FUNCTIONS . 'database.php');

to

// include the database functions
require_once(DIR_WS_FUNCTIONS . 'database.php');

That needs to be done also in application_top.php. Probably, the error will go away (it is a problem of loading twice, not allowed).

Timo Jensen

Link to comment
Share on other sites

I changed both places, but same result.

It only happens when i click "affiliate information" on my front page.

http://drikkegel.dk/catalog/affiliate_info.php

Hmm, perhaps try to comment out that line:

// require_once(DIR_WS_FUNCTIONS . 'database.php');

Might not be needed after all.

 

Sure you get the same error? Because I get:

Cannot redeclare tep_exit() (previously declared in /home/drikkege/public_html/catalog/includes/functions/general.php:16)

Which has a similar cause, but a different file that is "required" twice.

Link to comment
Share on other sites

Sure you get the same error? Because I get:

Cannot redeclare tep_exit() (previously declared in /home/drikkege/public_html/catalog/includes/functions/general.php:16)

Which has a similar cause, but a different file that is "required" twice.

 

I'm sorry. I get the same error you do. Off course.

Commenting out the line, does not help. Same error.

I also tried commenting the line in application_top.php. That seems to have no effect at all.

Timo Jensen

Link to comment
Share on other sites

Commenting out the line, does not help. Same error.

I also tried commenting the line in application_top.php. That seems to have no effect at all.

The first thing you did, change the require to require_once solved the first error, but now you get the same kind or error for another file that is "require"d again in one of the "affiliate" files. You have to do the same thing again: look for any "require"s in the affililiate contribution files and change it to require_once and do the same in application_top.

 

Commenting out the line in application_top.php is not a good idea: those required files are needed for good functioning of the shop but then can be loaded only once, not twice as that contribution is doing.

Link to comment
Share on other sites

The first thing you did, change the require to require_once solved the first error, but now you get the same kind or error for another file that is "require"d again in one of the "affiliate" files. You have to do the same thing again: look for any "require"s in the affililiate contribution files and change it to require_once and do the same in application_top.

 

Commenting out the line in application_top.php is not a good idea: those required files are needed for good functioning of the shop but then can be loaded only once, not twice as that contribution is doing.

 

just a thought - have you edited any files resulting in that error

 

If so go back and make sure there are no blank lines at the beginning or the end of the files you edited - if so delete the blank lines

 

just a thought

Regards

 

Mark A Reynolds

Link to comment
Share on other sites

The first thing you did, change the require to require_once solved the first error, but now you get the same kind or error for another file that is "require"d again in one of the "affiliate" files. You have to do the same thing again: look for any "require"s in the affililiate contribution files and change it to require_once and do the same in application_top.

 

Commenting out the line in application_top.php is not a good idea: those required files are needed for good functioning of the shop but then can be loaded only once, not twice as that contribution is doing.

 

Changing require to require_once in all statements, made it work.

Thank you. Now i just need to get the banners showing :-)

Timo Jensen

Link to comment
Share on other sites

just a thought - have you edited any files resulting in that error

 

If so go back and make sure there are no blank lines at the beginning or the end of the files you edited - if so delete the blank lines

 

just a thought

 

Hi Mark. I only edited what the "install.txt" told me to. And followed the advise given here. It did not work from the beginning, but editing application_top, did the trick.

 

But thanks for the advise.

Timo Jensen

Link to comment
Share on other sites

The first thing you did, change the require to require_once solved the first error, but now you get the same kind or error for another file that is "require"d again in one of the "affiliate" files. You have to do the same thing again: look for any "require"s in the affililiate contribution files and change it to require_once and do the same in application_top.

 

Commenting out the line in application_top.php is not a good idea: those required files are needed for good functioning of the shop but then can be loaded only once, not twice as that contribution is doing.

I thought it helped, but now it seems like my shop is included in the footer.

I tried removing some of the corrections to application_top.php, but they are all needed to show the page.

I just one statement is only "require", i get the error as before. Only in diffferent lines.

Timo Jensen

Link to comment
Share on other sites

  • 2 weeks later...

Er. Ignore this, I replied in the wrong tab.

Edited by Gil_e_n

Always BACK UP your files and your database before making any changes. Before asking questions, check out the Knowledge Base. Check out the contributions to see if your problem's solved there. Search the forums.

 

Useful threads: Store Speed Optimization How to make a horrible shop Basics for design change How to search the forums

 

Useful contributions: Easypopulate Fast, Easy Checkout Header Tag Controller

Link to comment
Share on other sites

  • 8 months later...

just a quick note for late comers like me to this thread.

 

i had the same problem after a CLEAN install.

 

to fix it i did the sql as mentioned

 

ALTER TABLE `affiliate_banners` ADD `affiliate_category_id` INT DEFAULT '0' NOT NULL AFTER `affiliate_products_id` ;

 

i also made sure in appliction_top, both in catalog and admin there was no gaps before the end ?>

 

and it now works fine

 

hope that helps someone

 

tim

 

THANKS to porcella and Janz for nutting it out for us

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...