I am using Slim framework to create api for my application. I canβt connect to Google Cloud SQL.
I submitted the error message below.
I use this in codeigniter without any problems. Can someone help me figure out how to fix this problem.
DB Code:
function getDB() {
$dbhost=":/cloudsql/projid:instancename";
$dbuser="root";
$dbpass="";
$dbname="dbname";
$dbConnection = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $dbConnection;
}
Error message
{"error":{"text":SQLSTATE[HY000] [2002] php_network_getaddresses: gethostbyname failed. errno=0}}
PS I do not encounter this problem on Localhost.
Krish source
share