Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

FATAL ERROR on database.php line 13


JJMikhail

Recommended Posts

Hello all, my first post. I have found this forum very helpful and its solved most of my issues on the web. However, whilst trying to configure everything before I start using the site to sell goods, I have a problem with the following on the admin page. Is there anyone that share some light on this issue? The coding below the error is of the database.php, hope it helps. This is actually after being in the index.php on the administration side of things, and when I click on 'My Account' and 'Administrator', options available from the action menu.

 

Thanks,

Joseph

 

 

 

________________________

Fatal error: Cannot redeclare tep_db_connect() (previously declared in /content/StartupHostPlus/s/e/second-handgoods.com/web/catalog/admin/includes/functions/database.php:13) in /content/StartupHostPlus/s/e/second-handgoods.com/web/catalog/admin/includes/functions/database.php on line 13

________________________

<?php

/*

$Id: database.php,v 1.23 2003/06/20 00:18:30 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright ? 2003 osCommerce

 

Released under the GNU General Public License

*/

 

function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') {

global $$link;

 

if (USE_PCONNECT == 'true') {

$$link = mysql_pconnect($server, $username, $password);

} else {

$$link = mysql_connect($server, $username, $password);

}

 

if ($$link) mysql_select_db($database);

 

return $$link;

}

 

function tep_db_close($link = 'db_link') {

global $$link;

 

return mysql_close($$link);

}

 

function tep_db_error($query, $errno, $error) {

die('<font color="#000000"><b>' . $errno . ' - ' . $error . '<br><br>' . $query . '<br><br><small><font color="#ff0000">[TEP STOP]</font></small><br><br></b></font>');

}

 

function tep_db_query($query, $link = 'db_link') {

global $$link, $logger;

 

if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {

if (!is_object($logger)) $logger = new logger;

$logger->write($query, 'QUERY');

}

 

$result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error());

 

if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {

if (mysql_error()) $logger->write(mysql_error(), 'ERROR');

}

 

return $result;

}

 

function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $link = 'db_link') {

reset($data);

if ($action == 'insert') {

$query = 'insert into ' . $table . ' (';

while (list($columns, ) = each($data)) {

$query .= $columns . ', ';

}

$query = substr($query, 0, -2) . ') values (';

reset($data);

while (list(, $value) = each($data)) {

switch ((string)$value) {

case 'now()':

$query .= 'now(), ';

break;

case 'null':

$query .= 'null, ';

break;

default:

$query .= '\'' . tep_db_input($value) . '\', ';

break;

}

}

$query = substr($query, 0, -2) . ')';

} elseif ($action == 'update') {

$query = 'update ' . $table . ' set ';

while (list($columns, $value) = each($data)) {

switch ((string)$value) {

case 'now()':

$query .= $columns . ' = now(), ';

break;

case 'null':

$query .= $columns .= ' = null, ';

break;

default:

$query .= $columns . ' = \'' . tep_db_input($value) . '\', ';

break;

}

}

$query = substr($query, 0, -2) . ' where ' . $parameters;

}

 

return tep_db_query($query, $link);

}

 

function tep_db_fetch_array($db_query) {

return mysql_fetch_array($db_query, MYSQL_ASSOC);

}

 

function tep_db_result($result, $row, $field = '') {

return mysql_result($result, $row, $field);

}

 

function tep_db_num_rows($db_query) {

return mysql_num_rows($db_query);

}

 

function tep_db_data_seek($db_query, $row_number) {

return mysql_data_seek($db_query, $row_number);

}

 

function tep_db_insert_id() {

return mysql_insert_id();

}

 

function tep_db_free_result($db_query) {

return mysql_free_result($db_query);

}

 

function tep_db_fetch_fields($db_query) {

return mysql_fetch_field($db_query);

}

 

function tep_db_output($string) {

return htmlspecialchars($string);

}

 

function tep_db_input($string, $link = 'db_link') {

global $$link;

 

if (function_exists('mysql_real_escape_string')) {

return mysql_real_escape_string($string, $$link);

} elseif (function_exists('mysql_escape_string')) {

return mysql_escape_string($string);

}

 

return addslashes($string);

}

 

function tep_db_prepare_input($string) {

if (is_string($string)) {

return trim(stripslashes($string));

} elseif (is_array($string)) {

reset($string);

while (list($key, $value) = each($string)) {

$string[$key] = tep_db_prepare_input($value);

}

return $string;

} else {

return $string;

}

}

?>

Link to comment
Share on other sites

That error isn't caused by that file. There is a mistake in one of your files that is attempting to reload something already loaded. This could be in one of the files in the root or in the languages directory. You will need to play detective to find the problem. Does it fail for all of admin? Can you go straight to a page, like admin/customers.phph? If it is always failing, then you may need to replace files until the problem is isolated.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

That error isn't caused by that file. There is a mistake in one of your files that is attempting to reload something already loaded. This could be in one of the files in the root or in the languages directory. You will need to play detective to find the problem. Does it fail for all of admin? Can you go straight to a page, like admin/customers.phph? If it is always failing, then you may need to replace files until the problem is isolated.

 

Jack

 

Thanks for the reply, no everything else works, the log off admin goes to a blank page, however, I cant imagine it being anything else. In other words, are you trying to say that I have to look into each file and find that line??

 

THanks again.

Link to comment
Share on other sites

It depends. I may not understand your problem. What do you do to see the failure? Are you saying the only time it fails is when you click the logoff link in admin?

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

It depends. I may not understand your problem. What do you do to see the failure? Are you saying the only time it fails is when you click the logoff link in admin?

 

Jack

 

I'm having the same problem with the product_info.php file. All other pages work fine.

Fatal error: Cannot redeclare tep_db_connect() (previously declared in /path/to/catalog/includes/functions/database.php:13) in /path/to/catalog/includes/functions/database.php on line 13

 

In database.php I added:

if(!defined("tep_db_connect")) {

...

}

 

Apparently it's not defined anywhere else because the error remains. Any other ideas?

 

Jim

Link to comment
Share on other sites

That error isn't caused by that file. There is a mistake in one of your files that is attempting to reload something already loaded. This could be in one of the files in the root or in the languages directory. You will need to play detective to find the problem. Does it fail for all of admin? Can you go straight to a page, like admin/customers.phph? If it is always failing, then you may need to replace files until the problem is isolated.

 

Jack

 

Jack,

 

Looking in the documentation, I see the file \oscommerce_documentation-20051220\e_cannot_redeclare_tep_db_connect.html

 

It states:

The following error message is shown when a main code file has been uploaded to the languages directory by accident.

 

Cannot redeclare tep_db_connect() (previously declared in /home/username/public_html/store/includes/functions/database.php:13)

 

Solution

Upload the correct file to the languages/*/ directory where * is the name of the language you are using.

 

I deleted all the files in the language folder and replaced them with the originals so that there are only the files htat belong there. Every other page works properly except product_info.php and I even replaced that. Nothing in the database.php or configure.php overlap.

 

If I find the cause I'll let you know. But if you have a direction I can investigate, please let me know.

 

Jim

Link to comment
Share on other sites

________________________

Fatal error: Cannot redeclare tep_db_connect() (previously declared in /content/StartupHostPlus/s/e/second-handgoods.com/web/catalog/admin/includes/functions/database.php:13) in /content/StartupHostPlus/s/e/second-handgoods.com/web/catalog/admin/includes/functions/database.php on line 13

________________________

 

I found the error in the STS template system. When I downloaded the package and replaced some of the files, the error went away.

 

Get the package here http://www.oscommerce.com/community/contributions,1524

 

The upload all the files named sts_* in the primary zip folder.

sts_display_output.php

sts_restart_capture.php

sts_start_capture.php

sts_stop_capture.php

sts_user_code.php

 

Jim

Link to comment
Share on other sites

So, the error you found wasn't in the STS system (it sounds that way in your post), but in your installation of it?

 

Vger

 

The problem was in the STS system. Apparently something didn't transfer properly when I moved the shopping cart to another site. Now there's one more item to work out - the heading on the catalog page. It's using the same template but is the only page that the images don't line up properly.

 

The site I'm working on it http://www.tonerdealers.com

 

Thanks

 

Jim

Link to comment
Share on other sites

Joseph,

 

did you find a solution yet? I had a very similar problem but on a different file. Check out this page,

 

http://www.oscommerce.com/forums/index.php?sho...74entry612574

 

For me the line 13 problem was just having the wrong page on the server. Hope it works out for you.

 

 

Hello all, my first post. I have found this forum very helpful and its solved most of my issues on the web. However, whilst trying to configure everything before I start using the site to sell goods, I have a problem with the following on the admin page. Is there anyone that share some light on this issue? The coding below the error is of the database.php, hope it helps. This is actually after being in the index.php on the administration side of things, and when I click on 'My Account' and 'Administrator', options available from the action menu.

 

Thanks,

Joseph

________________________

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...