Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Quick question re database intermittently dropping out


peterpil19

Recommended Posts

Hi there,

 

When going to my store occasionally I am met with the following error:

 

Warning: mysqli_connect(): (HY000/2005): Unknown MySQL server host 'ancientcointraders.com' (2) in /home/[my username]/public_html/includes/functions/database.php on line 20
Unable to connect to database server!

 

 

Is there anything in Oscommerce settings which could be contributing to this or is it more likely an issue with hosting?

 

At first I thought it had to be the hosting, yet I can still log into cpanel, and access the database itself at the same time as the website displaying the error (even after refreshing cache in browser).

 

I've raised it with my hosting company and they said they cannot see anything wrong on their end.

 

Just trying to rule out where the issue might be coming from.

 

Peter

CE PHOENIX SUPPORTER

Support the Project, go PRO and get access to certified add ons

Full-time I am a C-suite executive of a large retail company in Australia. In my spare time, I enjoying learning about web-design.

Download the latest version of CE Phoenix from gitHub here

Link to comment
Share on other sites

@@peterpil19

 

I doubt it's a hosting issue. Some simple things to look for. In your includes/configure.php file, how are you trying to connect to the db. Is it with localhost or 127.0.0.1? No matter which your using, it should match in your php.ini file. Search for mysql.default_host = "127.0.0.1" -OR- mysql.default_host = "localhost" in your php.ini file and see what it says. Then look at the includes/configure.php file for the define('DB_SERVER', '127.0.0.1'); -OR- define('DB_SERVER', 'localhost'); They should match. If one is localhost and the other is 127.0.0.1, it can cause a glitch. The glitch being the intermittent problem you mentioned. I prefer 127.0.0.1, it seems to be a tiny bit faster than localhost.

 

Below is a good connection to the db. If it doesn't look very similar to this, you can have a bad connection. It will throw up errors as well as log errors. Look in your errors.log file for more clues. Please post what you find in there and we can help you a little more.

 

  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') {
      $server = 'p:' . $server;
    }

    $$link = mysqli_connect($server, $username, $password, $database);

    if ( !mysqli_connect_errno() ) {
      mysqli_set_charset($$link, 'utf8');
    }

    return $$link;
  }

 

Take care

Bill

Link to comment
Share on other sites

The error message says that the MySQL library is trying to connect to the MySQL DB server at 'ancientcointraders.com', which sounds more like your site's domain name. Are you doing something different when this fails (using a different system or module) than when it runs OK? Maybe it's using a different configuration file that's set up wrong: the DB server is usually either localhost or 127.0.0.1 if it is running on your site server's machine, or it should be another IP address or resolvable name if it's running on a separate server. It would be most unusual to have the server using your domain name (but it might be possible to set up a system that way). If you are definitely using the same code and same configuration, and it's just an occasional failure, I would guess that your configuration.php file is being misread, and sending bad information. This could indicate a failing disk drive, so don't hesitate to let your host know about it so they can keep an eye on it.

Link to comment
Share on other sites

The error message says that the MySQL library is trying to connect to the MySQL DB server at 'ancientcointraders.com', which sounds more like your site's domain name. Are you doing something different when this fails (using a different system or module) than when it runs OK? Maybe it's using a different configuration file that's set up wrong: the DB server is usually either localhost or 127.0.0.1 if it is running on your site server's machine, or it should be another IP address or resolvable name if it's running on a separate server. It would be most unusual to have the server using your domain name (but it might be possible to set up a system that way). If you are definitely using the same code and same configuration, and it's just an occasional failure, I would guess that your configuration.php file is being misread, and sending bad information. This could indicate a failing disk drive, so don't hesitate to let your host know about it so they can keep an eye on it.

 

Thanks,

 

I have changed it to 127.0.0.1.

I don't know how it ended up with my domain name instead as I followed the instruction prompts when installing osCommerce.

 

Peter

CE PHOENIX SUPPORTER

Support the Project, go PRO and get access to certified add ons

Full-time I am a C-suite executive of a large retail company in Australia. In my spare time, I enjoying learning about web-design.

Download the latest version of CE Phoenix from gitHub here

Link to comment
Share on other sites

  • 4 weeks later...

The error message says that the MySQL library is trying to connect to the MySQL DB server at 'ancientcointraders.com', which sounds more like your site's domain name. Are you doing something different when this fails (using a different system or module) than when it runs OK? Maybe it's using a different configuration file that's set up wrong: the DB server is usually either localhost or 127.0.0.1 if it is running on your site server's machine, or it should be another IP address or resolvable name if it's running on a separate server. It would be most unusual to have the server using your domain name (but it might be possible to set up a system that way). If you are definitely using the same code and same configuration, and it's just an occasional failure, I would guess that your configuration.php file is being misread, and sending bad information. This could indicate a failing disk drive, so don't hesitate to let your host know about it so they can keep an eye on it.

 

This issue continued to appear intermittently when in the Admin area and then I realised I had not updated the configure.php in the Admin / includes directory, just the one in the Catalog / includes directory. A good reminder to anyone that has similar issues that you need to update the DB server in 2 locations.

 

A rookie mistake to name the DB server the domain name when I first installed it.

 

Peter

CE PHOENIX SUPPORTER

Support the Project, go PRO and get access to certified add ons

Full-time I am a C-suite executive of a large retail company in Australia. In my spare time, I enjoying learning about web-design.

Download the latest version of CE Phoenix from gitHub here

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...