I can connect to mysql just fine with my port number through the command line like so:
mysql -h ##.##.##.## -P 3307 -u wpuser -p
I have a php file that tries to connect to the DB,
<?php
include("/path to wordpress directory/wp-config.php");
$conn = new mysqli( DB_HOST, DB_USER, DB_PASSWORD, DB_NAME );
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
and I keep receiving this error:
Connection failed: Unknown MySQL server host '##.##.##.##:3307' (1)
It does not seem to be able to connect to that host/port even though I successfully can through the command line.
I have tried manually writing the DB credentials in my $conn variable so i know that is not the issue.
I can connect to mysql just fine with my port number through the command line like so:
mysql -h ##.##.##.## -P 3307 -u wpuser -p
I have a php file that tries to connect to the DB,
<?php
include("/path to wordpress directory/wp-config.php");
$conn = new mysqli( DB_HOST, DB_USER, DB_PASSWORD, DB_NAME );
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
and I keep receiving this error:
Connection failed: Unknown MySQL server host '##.##.##.##:3307' (1)
It does not seem to be able to connect to that host/port even though I successfully can through the command line.
I have tried manually writing the DB credentials in my $conn variable so i know that is not the issue.
Share Improve this question asked Dec 14, 2016 at 20:34 Curious_oneCurious_one 112 bronze badges 1- This does not sound WordPress related. – czerspalace Commented Dec 14, 2016 at 23:07
1 Answer
Reset to default 1Try this one. This is connection object created to use in wordpress
$mydb = new wpdb( 'username', 'password', 'my_database', 'localhost' );
and if it is way that you want to go check in codex $wpdb function 'select' to select database when do queries. Hope it help.