Monday, March 14, 2016

[google-cloud-sql-discuss] Trying to Connect to database in PHP using PDO and Cloud SQL Proxy

I tried to connect  to database in  PHP using PDO and Cloud SQL Proxy but have no luck. I keep getting 



Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory'

Im using

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
$pdo = new PDO('mysql:unix_socket=/cloudsql/<your-project-id>:<your-instance-name>;dbname=db', 
'db', 
'db'
);
$statement = $pdo->query("SHOW TABLES;");
$row = $statement->fetch(PDO::FETCH_ASSOC);
echo htmlentities($row['_message']);
?>

Has anyone had any luck connecting

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/411eb6c1-fafa-4613-812d-b36728f447d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment