How to connect to Google Cloud SQL Database from GoDaddy Server - php

I am trying to connect to a sql instance on google cloud from a website that is hosted on a godaddy server.
I am getting the following error
Failed to connect to MySQL: Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (110)
I have authorized the IP to my godaddy server.
Here is how I am handling my connection...
<?php
// Change this to your connection info.
$DATABASE_HOST = 'xxx.xxx.xxx.xxx';
$DATABASE_USER = 'user';
$DATABASE_PASS = 'pass';
$DATABASE_NAME = 'db';
// Try and connect using the info above.
$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
if ( mysqli_connect_errno() ) {
// If there is an error with the connection, stop the script and display the error.
die ('Failed to connect to MySQL: ' . mysqli_connect_error());
}
?>
I have been STUCK for a little while and have not seen anything on the web to help.

Related

Connect to remotemysql.com on my website?

I want to connect a database on remotemysql.com too my website (ddu.nu/3/weatherstation). When i try to run the connection to the database on the website the connection fails. But when i try the exact same code on the localhsot the connection is created. Here is the code that i am using.
$connect = mysqli_connect("remotemysql.com:3306", "dbuser", "dbpass", "dbname");
if(!$connect ) {
die('Connection failed: ' . mysqli_error());
}
echo 'Connected successfully';
The website doesn't give any error.
Here is the website
And here is the localhost
My quetion is what I need to do in order for the real website to function.
You should try to disable ssl or the ssl have to have ssl cert, mine is work pefectly with ssl disable:
String dbURL = "jdbc:mysql://remotemysql.com:3306/";
Connection con = DriverManager.getConnection(dbURL + dbName + "?useSSL=false",
dbUsername,
dbPassword);

Filezilla Connect through PHP

I am trying to upload a file from my machine (client side) to the FileZilla server (server side) I have for storing the web page files.
When trying to connect to FileZilla through PHP I receive the following error message:
Connection failed: Connection refused
Usually, I would expect the error when the login credentials are incorrect, however, in this case, they are correct.
My question: Can you connect to FileZilla via PHP? I am sure the answer must be 'Yes' however due to the technical difficulties currently I would not be surprised otherwise.
Potentially there is an error in the formatting of the connection function.
var $host = "xx.xx.xx.xx";
var $user = "xx";
var $pass = "xx";
var $connect;
function serverConnection()
{
$conection = mysqli_connect($this->host, $this->user, $this->pass) or die
("Connection failed: " . mysqli_connect_error());
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
} else {
$this->connect = $conection;
}
return $this->connect;
}
The goal is to be able to upload files from a form to FileZilla, to act as users profile pictures.
Currently, you're using mysqli_connect which connects to a database server, you need to connect to an FTP server, so you should use the FTP functions. You should first connect and then login.
It should look something like this:
$server = 'myServer';
$user = 'myUsername';
$pass = 'myPassword';
$connect = ftp_connect($server) or die('Could not connect to FTP-server.');
if(ftp_login($connect, $user, $pass)) {
echo 'Connected to FTP-server.';
}

How to connect to my remote Mysql Database via Xampp

I am using Xampp to update my website and since I have added a Mysql database I have the error further down locally while it works fine online.
I'm using the code below to connect to my database:
<?php
$servername = "myservername";
$username = "myusername";
$password = "mypassword";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
http://localhost/connectdb.php
Result:
Connection failed: php_network_getaddresses: getaddrinfo failed: No
such host is known.
http://example.com/connectdb.php
Result:
Connected successfully
So there must be some configuration to do in Xampp to access a remote database or do I need to ask my host to whitelist my private IP Address? My host is OVH.
Thanks for your help

connection error while using php and sql server 2008

Connection failed: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
as i establish connection between my computer and remote machine using "php" and sql server 2008 respectively. i got this error.
<?php
$servername = "";
$username = "";
$password = "";
$dbname = "complaint";
// Create connection
$conn = new mysqli($servername, $username, $password,$dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
You must have a defined servername, username and password. If the server is local than use "localhost" if it is a remote server use IP "X.X.X.X"

mssql_connect() Unable to connect to server to Remote host from php hosting

I have working mssql connecting codes and them working in my another company php host but dont work when i moved new host. All codes same i dont know why connect from new host ? In new host using cpanel and php ( Hostgator ) and im looking php.ini in cpanel mssql settings looking good. my codes below under.
$usernameb ="myuser";
$passwordb = "mypass";
$databaseb = "mydb";
$host ="myhostip"
$connection = mssql_connect($host, $usernameb, $passwordb);
if (!$connection) { die('Not connected : ' . mssql_get_last_message());}
$db_selected = mssql_select_db($databaseb, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mssql_get_last_message());
} else{
}
And gives that error on my new hosting
Warning: mssql_connect(): Unable to connect to server: ip here in
Any idea ?

Categories