Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

updating sql database


mom4x

Recommended Posts

I'm hoping to upgrade my files as I'm having some errors, and hope to fix them this way.

 

could someone point me in the right direction? There are so many forums to search through. wow

 

thanks!!!!

Link to comment
Share on other sites

The most likely cause for your errors is not the database but one of the individual files. When the error is displayed it usually gives a good clue on what the problem is or at least where it can be found (in what file). Only if you get a tep_db_stop error there's a problem with referencing the database. This too is usually a coding error in the files, not the database.

 

You cannot access your database like you proposed, because the database is for all purposes that matter right now not a bunch of files you can copy or edit. Therefore you won't find it in your osCommerce directories. You can most likely use phpMyAdmin to access your database.

 

HTH,

Willem.

Link to comment
Share on other sites

I will start from the beginning.

 

I haven't done anything with my site so I'm not certain why I'm getting errors.

 

However, the first one was noticed yesterday. Went to load my site to check on things and it would load, but showed this error:

 

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/tmp/mysql.sock' (13) in /home/homescho/public_html/includes/functions/database.php on line 19

Unable to connect to database server

 

Then I asked for a copy of a database file.

 

Someone gave me a copy of their database file and my site was viewable but had another warning:

 

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/homescho/public_html/includes/configure.php:45) in /home/homescho/public_html/includes/functions/sessions.php on line 67

 

What should I do? Appreciate any help!

Link to comment
Share on other sites

have you changed your configure.php files? The only reason I can think of why you can't connect to your database is because your database settings in configure.php are wrong. The second error might very well be related to that.

 

Yout said someone gave you their database file. I am not sure what you mean by that, it would help if you could give the filename of this database? Just to verify if you are actually talking about a backup of the database or something else.

Link to comment
Share on other sites

No, I hadn't changed my configure.php file or changed anything of any sort. This is why I'm stumpted.

 

I noticed the error yesterday afternoon after checking for orders, etc.. The site had been viewed earlier in the day and loaded fine.

 

I posted my concern on a forum of my hosting site. Very similar to this forum. Someone responded, giving me a copy of what the file should look like so I could compare. Just for the sake of trying, I loaded their version and my site showed up. However, the other error then occured. I saved my original file that seems to be causing the errors and will post it here in hopes that someone will have some advice.

 

The file is located in public_html/includes/functions/database.php

 

<?php
/*
 $Id: database.php,v 1.17 2002/06/05 11:16:03 hpdl Exp $

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

 Copyright (c) 2002 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;

   if (STORE_DB_TRANSACTIONS == 'true') {
      error_log("QUERY " . $query . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
   }

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

   if (STORE_DB_TRANSACTIONS == 'true') {
      $result_error = mysql_error();
      error_log("RESULT " . $result . " " . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
   }

   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_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 stripslashes($string);
 }

 function tep_db_input($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;
   }
 }
?>

 

I would appreciate any help so my site returns to normal. Thank you

Link to comment
Share on other sites

I'm afraid I don't know what the problem is either... however, just thought I'd note: this is not your database, it is merely a file with functions to access databases. Backing up this file in the future does not backup your database.

 

I can't help you with anything else I'm afraid :(

Link to comment
Share on other sites

Given the symptoms that you have described here, I would guess that your configure.php has become corrupted. You should restore this file from a backup copy and see if that helps. There may be other files damaged as well.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

My host informed me that the database was down. That is what has caused my problems from the beginning.

 

Thanks to all for your time and efforts to help me out.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...