Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Fatal error after server crash


auster

Recommended Posts

Hi,

My Hosting server crashed last Friday. It's since been restored from a back up I'm told, but now I'm getting the following error when trying to open the oscommerce part of the website:-

Fatal error: Uncaught Error: Call to undefined function mysql_select_db() in /home/pumabuil/public_html/pumacat/includes/functions/database.php:22 Stack trace: #0 /home/pumabuil/public_html/pumacat/includes/application_top.php(65): tep_db_connect() #1 /home/pumabuil/public_html/pumacat/index.php(13): require('/home/pumabuil/...') #2 {main} thrown in /home/pumabuil/public_html/pumacat/includes/functions/database.php on line 22

I queried it and the only answer I got was that it was an error in my code! I hadn't changed anything prior to the server crash.

Any help would be appreciated, please.

Link to comment
Share on other sites

The error is saying it can't find the mysql_select_db function. That is a standard function for older versions of php. It may or may not be in the newer versions. So my guess is that your host either installed a newer version of php when they repaired the server or they compiled php without the MySQL functions. What to do depends on your version of oscommerce.

The easy fix is to ask your host to recompile php with MySQL. If they won't, then you can try changing your code to use mysqli. It might or might not work. Or you can upgrade  your shop to the latest community version. The last one is what I recommended but it is not quick so probably is not an option since your site is down.

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

Run the following script (.php file)

 <?php phpinfo(); ?>

and examine the output to see whether MySQL and/or MySQLi are enabled. Any PHP built in the last decade should support MySQLi, while recent PHP builds may not have MySQL any longer. You should have at least one of them available, or your host has fallen down on the job. By the way, do NOT give out the file name (URL) or list the results publicly, as it contains information that could be used to hack your site.

Recent osC versions prefer MySQLi, but will run with MySQL. If you have an ancient osC version (e.g., 2.2), it will support only MySQL. If your host no longer offers MySQL, your only choice is to upgrade to the current "Edge" release.

Link to comment
Share on other sites

I changed the three instances of mysql to mysqli, do I have to change it anywhere else in database.php?

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 = mysqli_pconnect($server, $username, $password);
    } else {
      $$link = mysqli_connect($server, $username, $password);
    }

    if ($$link) mysqli_select_db($database);

 

I now get this additional Warning:-

Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in /home/pumabuil/public_html/pumacat/includes/functions/database.php on line 22

Fatal error: Uncaught Error: Call to undefined function mysql_query() in /home/pumabuil/public_html/pumacat/includes/functions/database.php:44 Stack trace: #0 /home/pumabuil/public_html/pumacat/includes/application_top.php(68): tep_db_query('select configur...') #1 /home/pumabuil/public_html/pumacat/index.php(13): require('/home/pumabuil/...') #2 {main} thrown in /home/pumabuil/public_html/pumacat/includes/functions/database.php on line 44

Link to comment
Share on other sites

Did you ask your host to recompile php to include MySQL. If they refuse, especially since this is their fault, it may be time to look for another host.

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

These are the last few exchanges of a long online 'support' chat!

I do sincerely apologize, however, this issue falls outside of what HostGator live support is able to troubleshoot and resolve. While I have tried my best to find a resolution to the issue you are experiencing, Unfortunately, it appears I have exhausted all avenues that I have in live support to get your issue corrected. I recommend contacting a professional web developer or a development support forum for your software.

Me: But why can't your technicians simply add mysql functions in PHP7 in addition to mysqli functions, it's perfectly possible?

We did everything to solve it how ever, this issue needs to be addressed by a Web Developer as it is out of our scope of support.

Me: With respect have you asked your technicians to add mysql funtions to PHP 7?

Yes we did add that information.

Me: And are they saying that it can't be done, or that they are not willing to do it?

We did everything to solve the issue. However, the issue is still existing. Fixing issues with codes is not supported within live chat but we did extend our support for you. Please do contact a web developer to further assist you as this is out of our scope of support.

Me: Disgusting, given that the problem was caused by your server crash

I understand. Our Engineers are doing their best to resolve on the server issue but this issues is caused by codes.

If you know the process, please do it as we do not support coding issue.

Me: I don't have access to your server! If your technicians don't know how to recompile PHP then you're going to have a lot of problems going forward!

That's it, they cut the online 'support' connection dead.

Can anyone help to upgrade oscommerce for a reasonable fee?

 

Link to comment
Share on other sites

auster You should get in touch with someone above that tech. Regardless of anything else, there is never a reason a support person should just sign-off like that. Plus, techs that answer live chat questions are usually just level 1 techs, sometimes just fresh out of school. There should be a way for you to escalate the problem.

With that being said, do you have to use php 7? If they offer 5.6 you may want to try that to see if it has MySQL in it.

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

There isn't any way to go higher up the chain, they only do support chat nowadays, not even an email address to put in a complaint to. I've had good service for several years from them but that's now gone.

As you may have gathered, my knowledge of oscommerce and coding in general is very limited.

How would I find out if 5.6 was available?

Link to comment
Share on other sites

2 minutes ago, Dan Cole said:

Selecting the PHP level should be an option in your cpanel. 

Only if the host has installed that option. It isn't automatic.

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

3 minutes ago, Jack_mcs said:

Only if the host has installed that option. It isn't automatic.

You're right Jack....maybe I should have used the word might instead of should but I'm sure Keiron will soon discover if his hosting package does or doesn't. 

Dan

Link to comment
Share on other sites

@auster

The best *quick* fix (assuming you have a full backup of your shop *and* the database) would be to move to a new host. Your only delay would be how long it would take for DNS to fully propagate.

If you do not have a full backup of your store *and* of your database, DO IT NOW! If you don't know how, just ask.

After that, you should really consider upgrading your shop to the latest Edge version of osCommerce (link in my signature below). It's not a simple in-place upgrade ... you would basically build a new store (usually in a temporary directory) and import your old data (customers, orders, etc) into the new store.

If any of this is beyond your ability, there are a number of developers that can quote you for something like this. Just post a request for quotation in the Commercial Support area of this forum:

https://www.oscommerce.com/forums/forum/79-commercial-support-inquiries/

Malcolm

Link to comment
Share on other sites

If you're all the way back on osC 2.3.1, I'm not sure it will run with even PHP 5.6, much less 7.0. No reputable host is going to routinely offer anything earlier than PHP 5.6 (which goes out of support at the end of 2018), so you need to think about getting up to "Edge" ASAP, where you can use PHP 7.0 and MySQLi.

Link to comment
Share on other sites

12 hours ago, auster said:

I changed the three instances of mysql to mysqli, do I have to change it anywhere else in database.php?

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 = mysqli_pconnect($server, $username, $password);
    } else {
      $$link = mysqli_connect($server, $username, $password);
    }

    if ($$link) mysqli_select_db($database);

 

I now get this additional Warning:-

Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in /home/pumabuil/public_html/pumacat/includes/functions/database.php on line 22

Fatal error: Uncaught Error: Call to undefined function mysql_query() in /home/pumabuil/public_html/pumacat/includes/functions/database.php:44 Stack trace: #0 /home/pumabuil/public_html/pumacat/includes/application_top.php(68): tep_db_query('select configur...') #1 /home/pumabuil/public_html/pumacat/index.php(13): require('/home/pumabuil/...') #2 {main} thrown in /home/pumabuil/public_html/pumacat/includes/functions/database.php on line 44

@auster, well, leaving HG was the best decision for me especially I was paying for dedicated servers that were old news.  It seems HG did provide you with PHP and Mysqli. Now, HG uses Centos, I recall, so they could easily install what you need from the repos. The problem was probably you are on a shared host it seems, so they can't configure the server just for you. Also, you really can't install mysql for php7 as it's deprecated.

http://php.net/manual/en/function.mysql-select-db.php

I think you are on the right track though, I would just go through the doc. It's not that bad I think you may just have to flip the arguments for mysqli functions when applicable. For example:

// mysql
$db_selected = mysql_select_db($dbname, $link);

// to mysqli
$db_selected = mysqli_select_db ( $link , $dbname )

So in your case to make the warning go away,

// just add the $link to the argument

if ($$link) mysqli_select_db($database, $link);

Try it, it may work...and please refer to the PHP doc...

http://php.net/manual/en/class.mysqli.php

The function lists are on the bottom of the page...

Oh, most of the functions that you need to mod to mysqli should be in this file.../home/pXXXl/public_html/pXXXt/includes/functions/database.php

Good luck!

Link to comment
Share on other sites

Thanks for all your help people, much appreciated.

However the client decided to move on and is having a completely new website using Worpress designed for him on his other .co.uk domain.

Mine is on his .com domain and that will be transferred to his new host too as and when.

Hey ho......

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...