I wanna use mysqli database connection inside my own websocket server. How can i use the database without defining the unix socket path? Like this:
$connection = new mysqli($db_servername, $db_username, $db_password, $db_name,3306,'/Applications/MAMP/tmp/mysql/mysql.sock');
The webSocket server is running on localhost:8080
. I also tried some other ports and hostnames but i got stil the same error:
Fatal error: Uncaught Error: Class 'mysqli' not found in D:\project\
$this->socketResource = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_set_option($this->socketResource, SOL_SOCKET, SO_REUSEADDR, 1);
socket_bind($this->socketResource, 0, $this->port);
socket_listen($this->socketResource);
public function connectToDatabase(){
$db_servername = "localhost";
$db_username = "root";
$db_password = "root";
$db_name = "dbname";
// Create connection
$connection = new mysqli($db_servername, $db_username, $db_password, $db_name);
return $connection;
}