Unable to create MySQLi Database via Php

code666

New member
Joined
Mar 28, 2024
Messages
2
Hello,

Our web application requires that we create database, tables and users with php. We are trying to use the following code:

<?php
include 'httpsocket.php';
$dbname = "testdatabase";
$dbuser = "testdatabase";
$dbpass = "testdatabase";

$sock = new HTTPSocket;
$sock->connect('domain.com',2222);

$sock->set_login("admin|da_admin","P@@sssw0rd");
echo '<pre>';
print_r($sock);
echo '</pre>';
$sock->set_method('POST');

$sock->query('/CMD_API_DATABASES',
array(
'action' => 'create',
'name' => $dbname,
'user' => $dbuser,
'passwd' => $dbpass,
'passwd2' => $dbpass
));
$result = $sock->fetch_body();
?>

We are getting the following output

HTTPSocket Object
(
[version] => 2.7.2
[method] => GET
[remote_host] =>domain.com
[remote_port] => 2222
[remote_uname] => admin|da_admin
[remote_passwd] => P@@sssw0rd
[result] =>
[result_header] =>
[result_body] =>
[result_status_code] =>
[lastTransferSpeed] =>
[bind_host] =>
[error] => Array
(
)

[warn] => Array
(
)

[query_cache] => Array
(
)

[doFollowLocationHeader] => 1
[redirectURL] =>
[max_redirects] => 5
[ssl_setting_message] => DirectAdmin appears to be using SSL. Change your script to connect to ssl://
[extra_headers] => Array
(
)

)

DirectAdmin appears to be using SSL. Change your script to connect to ssl://

Can someone please point us to the right direction?
 
create some extra input like $server and then use something like this:

Code:
$sock = new HTTPSocket;
$sock->connect("ssl://".$server,'2222');
 
Hi thank you. After changing it now the following error comes:

400 Bad Request: malformed Host header
 
Back
Top