Jump to content
syscon

osCommerce 2.2 [php7:error] mysql_connect()

Recommended Posts

I'm still running osCommerce 2.2 on php 5.6 when I tried to switch to php 7.3 when I try to admin login I get an error :

Quote

[php7:error] [pid 26589] [client 10.0.0.112:41184] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect() in /var/www/catalog/admin/includes/functions/database.php:19\nStack trace:\n#0 /var/www/catalog/admin/includes/application_top.php(63): tep_db_connect()\n#1 /var/www/catalog/admin/login.php(13): require('/var/www/syscon...')\n#2 {main}\n  thrown in /var/www/catalog/admin/includes/functions/database.php on line 19

I think it has something do to with new php 7 requirement.  The error refers to a code in database.php

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

Is there solution to it?

I was able to find from: 

https://www.php.net/manual/en/function.mysql-connect.php

The problem is with mysql_connect 

Quote

mysql_connect — Open a connection to a MySQL Server

Warning
This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:

mysqli_connect()
PDO::__construct()

 

Edited by syscon

#Joseph

Share this post


Link to post
Share on other sites

Go back through the old versions of osCommerce until you find where they switched from mysql_connect to mysqli_connect and then apply that set of changes.  Note that this is just the first of many changes that you will have to make, even just in that file.  Because every mysql_ function was deprecated, not just mysql_connect.  And there are many other changes needed for PHP 7. 

But anyway, the specific commit that you want is probably https://github.com/osCommerce/oscommerce2/commit/0064f6ce2208eaa972ebcc9e6772e45c7e3ee6fc#diff-611dd0e5f90ff998c01f8365dff385c1b0167b05eaf99d58fec24539b9a5b8fc

It might be easier to update to a newer version of osCommerce than to patch that one.  In particular, CE Phoenix is already PHP 7 compatible. 

Edited by ecartz

Always back up before making changes.

Share this post


Link to post
Share on other sites

@syscon

Without knowing exactly WHICH release of osC v2.2 you are running, please release that your version was released somewhere between 2003 and 2008. That was between 12 and 17 years ago! Those releases of osC were not written to run under PHP v7.x, because v7.x hadn't been released yet.

While the fact that you have had a store running for over a dozen years demonstrates what a great program osC is/was, it also points out that you have not kept your store code up to date

osC v2.2 will have MANY errors when you try to run it under PHP v7.x. While individuals have made the changes over time to 'update' v2.2 to run under PHP v7.x, there are;

1) no published instructions,

2) You will essentially be creating your own fork of osC, and no-one will be able to support it for you, and

3) It's time to update your site to the newest Community Edition of osC called Phoenix. It is NOT an in-place upgrade ... you will have to install Phoenix in its own directory, and migrate your data from your old store into Phoenix. If you do not feel you can do this yourself, there are a number of commercial developers here that can assist you in the migration.

HTH

Malcolm


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites
14 minutes ago, ArtcoInc said:

@syscon

Without knowing exactly WHICH release of osC v2.2 you are running, please release that your version was released somewhere between 2003 and 2008. That was between 12 and 17 years ago! Those releases of osC were not written to run under PHP v7.x, because v7.x hadn't been released yet.

While the fact that you have had a store running for over a dozen years demonstrates what a great program osC is/was, it also points out that you have not kept your store code up to date

osC v2.2 will have MANY errors when you try to run it under PHP v7.x. While individuals have made the changes over time to 'update' v2.2 to run under PHP v7.x, there are;

1) no published instructions,

2) You will essentially be creating your own fork of osC, and no-one will be able to support it for you, and

3) It's time to update your site to the newest Community Edition of osC called Phoenix. It is NOT an in-place upgrade ... you will have to install Phoenix in its own directory, and migrate your data from your old store into Phoenix. If you do not feel you can do this yourself, there are a number of commercial developers here that can assist you in the migration.

HTH

Malcolm

Yes, my osCommerce is very old: osCommerce v2.2 RC2

I think you might be right, the reason I  stick around this version for so long as it includes, credit-card modules that I used.  Does Phoenix include "credit-card module?

Are there any instructions on how to port/import the database information?

If not I'll have to install an older version of php. 5.6 and hopefully it will run on debian-stable or Gentoo.


#Joseph

Share this post


Link to post
Share on other sites

I imported my database (in Debian stable) to  MariaDB so can I install the new Phoenix-osCommerce and point it to that database?

 


#Joseph

Share this post


Link to post
Share on other sites
17 minutes ago, syscon said:

If not I'll have to install an older version of php. 5.6 and hopefully it will run on debian-stable or Gentoo.

Note that mysql_connect went in one of the PHP 5 versions -- I think 5.5 (look at the commit message that I linked previously).  So PHP 5.6 probably won't help with the specific problem that you're trying to work around now.  It would likely help you with other problems. 

5 minutes ago, syscon said:

I imported my database (in Debian stable) to  MariaDB so can I install the new Phoenix-osCommerce and point it to that database?

Burt posted instructions for updating from osCommerce to Phoenix.  It's probably somewhere in the Phoenix Club if you join that.  I don't remember specifics, but I believe that he was suggesting to build the Phoenix store first and then import the data into the tables there (not attempt to point Phoenix at the osC database).  There's also a list of tables not to port over, e.g. address_format, configuration, and sessions. 


Always back up before making changes.

Share this post


Link to post
Share on other sites

I'm currently running osCommerce 2.2 RC2 on MySQL 5.6.39 and  PHP-5.6.33  on Gentoo and it has been working for some time without any problems. The reason I'm upgrading (being force to upgrade) is that my Hard Drive is going slowly 😕 I have a backup but soon or later I'll be force to upgrade. 

Now I have to find that  Phoenix Club ;-/

Edited by syscon

#Joseph

Share this post


Link to post
Share on other sites

What is the difference between current osCommerce-v2.3.4.1 vs. OSCOM CE Phoenix Edition v1.0.7.9

It seems like a fork, but why?

Which one has a credit-card module?

There is a well osCommerce-v3 


#Joseph

Share this post


Link to post
Share on other sites

@syscon

The 'official' osCommerce project was lead by one person. After many years of hard work and development, Harold has chosen to work on other projects. In his absence, the "community" has continued with the development of osC. Harold does pop in here occasionally, and has given his permission to list the Community Edition as a sanctioned download. Unfortunately, he is the only one that can make this continued development an 'official' release.

The 'Community Edition' is a big improvement over the last 'official' v2.3.4 release in a number of ways:

1) It is responsive. This means that it will adjust the screen layout depending on the size of the screen of your customer's device. This is very important in this day of mobile devices. The 'official' version is not responsive.

2) It will work with the newer version of PHP, the scripting language used in osC. As more and more hosts upgrade their servers to PHP 7.x, older versions of osC (including the 'official' version) WILL CRASH!

3) It is much more modular. This means that you can turn features on or off, change the layout, or even add new features, all without touching the core code.


As I said, the community is still working on osC. Early editions did not have an accurate version numbering system, so there is often confusion as to which version a shop may be using. In July of last year (2019), the 'Phoenix' edition was released. Phoenix is the latest release, now with a consistent version numbering system in place. This numbering system does not relate to the 'official' osC numbering in any way.

osCommerce has a large library of add-ons. However, as new versions of osCommerce were released, a lot of these add-ons were not updated to work with the newer release. This is also true with Phoenix. A number of developers responsible for some of the more popular add-ons ARE updating their add-ons to work with Phoenix, but a lot of the older add-ons are not. This is not as much of a problem as it sounds, as a lot of the functionality these older add-ons gave is now built into Phoenix.

You keep mentioning a 'credit card module.' Who are you using for your credit card processing? Does your old module meet the current legal and security needs?

Again, upgrading to Phoenix is not an "in-place' update. You must make a clean install of Phoenix (either in another directory, or on another server), and migrate your data to it (products, customers, sales history, etc). The data tables have changed, so it's not a simple 'copy your old database over' process. You can use a database structure tool to compare the two databases, and tweak a COPY of your old database to work with Phoenix.

If you would like to see osC continue to grow, please consider joining the Phoenix club ...

https://forums.oscommerce.com/clubs/1-phoenix/


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

Thank you for the explanation, it makes sense.

We process all credit cards manually, in addition they are deleted as soon as we process the transaction and yes our legal / security are covered. 


#Joseph

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×