--I'm attempting a basic PHP connection as root user to a Google Cloud MySQL DB NOT from the App Engine PHP SDK but from a PHP script to be hosted by our current website hosting service. I intend on conI'm encountering a timeout error i.e.
> Warning: mysqli_connect(): (HY000/2002): Connection timed out in
> ....... on line 8As I'm already performing CRUD to databases in my instance from Java I'm aware that specific networks are authorised to access a Cloud SQL instance hence I made sure I added the IP address of our website hosting service to the list of authorised networks.Having read this although I'm not connecting from the App Engine PHP SDK I'm also aware the how the host value is set is very crucial so could this be where I'm going wrong?Below is my code:<?php
// 1.Create a database connection
define("DB_SERVER", "XXX.XXX.XXX.XX");
define("DB_USER", "root");
define("DB_PASS", "password");
define("DB_NAME", "dbname");
$connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASS);
// Test if connection occured
if (mysqli_connect_errno()) {
echo "";
die("DB connection failed: " . mysqli_connect_error() . "(".mysqli_connect_errno().")");
} else {
echo "DB connection worked !!!!";
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Users Log In DB access</title>
</head>
<body>
Content of the document......
</body>
</html>
<?php
if(isset($connection)) {
// 5. Close DB connection
mysqli_close($connection);
}
?>Is there a reason I'm encountering the above timeout error? Should I include the port i.e. 3306 in the server string?Once I can connect from the above code to my Cloud SQL DB then I intend on completing this tutorial with regards to connecting Android to a remote server.EDIT: Just as a mention I successfully connect to my Google Cloud SQL instance database with MySQL Workbench.Any ideas are appreciated.
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/3ebd4d26-0539-4ed1-a48a-406f8dc9d746%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.