Jump to content
e_risande

Database connection failed

Recommended Posts

My site has been running smoothly for a long time (10 years?). But today, we found it no longer connects to the database.

Below is the code that has been in place for years. Obviously, the items are all variables and I changed the values to protect the innocent.

Can anyone help me? The last thing that is hit is:     echo 'Set Connection';      Which is only there to script test. Thanks!

 

    var $dbhost = 'localhost';
    var $database_name = 'database_name_here';
    var $dbusername = 'username_here';
    var $dbpasswd = 'password_here';

    function ConnectToDatabase()
    {
      /* Database Stuff, do not modify below this line */
      echo 'Set Connection';
      $connection = mysql_pconnect("$this->dbhost","$this->dbusername","$this->dbpasswd")
      or die ("Couldn't connect to server.");

      echo 'Select DB';
      $db = mysql_select_db("$this->database_name", $connection)
      or die("Couldn't select database.");

      echo 'End';
    }

 

 

Share this post


Link to post
Share on other sites

 

Hi Erin

mysql_pconnect extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. This issue was occurring because your site was set to use our default PHP version, which we recently changed to PHP 7.3. You can view our announcement of this change and how to select a different version at https://blog.totalchoicehosting.com/2020/03/notice-default-php-version-change/

To correct this for your sites, we have set your site to use the older PHP 5.5 version via cPanel and it appears to be loading fine. I recommend contacting the author of your script to see if they offer a newer version that supports PHP 7.


Please check and if you are still facing any problem, submit a ticket at  https://support.totalchoicehosting.com/ and select department as technical and mention the issue to be resolved.  We will be glad to help.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...