We're currently hosting with LCN and have got a database which everything works fine, its basically an app that calls scripts on the host which login to a database using:
class DB{
private $dbHost = "huya.uksrv.co.uk";
private $dbUsername = "uname";
private $dbPassword = "pword";
private $dbName = "dbase";
public function __construct(){
if(!isset($this->db)){
// Connect to the database
$conn = new mysqli($this->dbHost, $this->dbUsername, $this->dbPassword, $this->dbName, 2083);
if($conn->connect_error){
die("Failed to connect with MySQL: " . $conn->connect_error);
}else{
$this->db = $conn;
}
}
}
Getting the error: Failed to connect with MySQL: MySQL server has gone away
The problem is, were changing hosting to cPanel and their database is a little different to what I'm used to, it doesn't give a normal login page ie:
https://www.mydbadmin.co.uk/index.php its now: https://huya.uksrv.co.uk:2083/3rdparty/index.php
I'm able to login to the database through cPanel and create tables etc, but I can run a script which normally would work fine on the other server.
I believe the problem is something to do with localhost and sockets but ive no clue how these work at all.
The new Database details are:
Server: Localhost via UNIX socket
Server type: MariaDB
Server connection: SSL is not being used Documentation
Server version: 10.3.24-MariaDB-log-cll-lve - MariaDB Server
Protocol version: 10
User: xxxxxxxxxxxxxx@localhost
Server charset: cp1252 West European (latin1)
The old Database details are:
Server: database.lcn.com via TCP/IP
Server type: MySQL
Server connection: SSL is not being used Documentation
Server version: 5.7.29-log - MySQL Community Server (GPL)
Protocol version: 10
User: xxxxxxxxxx@xxxx.namesco.net
Server charset: UTF-8 Unicode (utf8)
How can I modify the class DB{} code to connect to the new database? Is it possible as I know the old server was TCP/IP.