I am just starting out with Cloud SQL, so I'm sure there is a simple mistake I'm making.
I am able to connect to my Cloud instance via MySQL Workbench. I created a database and table, and was able to insert and select from this table from MySQL Workbench.
However, when I try to connect through my app engine, I am getting an error.
EDITED- Here's my code:
<?php
try{
$db = null;
$db = new pdo('mysql:unix_socket=/cloudsql/my-gae-appname:my-cloud-sql-instance;dbname=myschema', 'root', '');
mysql_select_db('myschema');
$action = $_GET["action"];
$mapid = $_GET["mapid"];
$src = $_GET["src"];
$ip = $_SERVER["REMOTE_ADDR"];
$stmt = $db->prepare('INSERT INTO myschema.report (action, mapid, ip, source) VALUES (?,?,?,?)');
$stmt->execute(array($action, $mapid, $ip, $src));
$affected_rows = $stmt->rowCount();
echo $affected_rows;
$db = null;
}catch(PDOException $ex){
echo $ex->getMessage();
}
?>
The error I get is: SQLSTATE[HY000] [1049] Unknown database 'dpe'
Thanks!
error_reporting(E_ALL); ini_set('display_errors', '1');and$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);below the connection - Kevinmysql_select_dband PDO. - Funk Forty Niner$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);- as per php.net/manual/en/pdo.connections.php - So, why are you usingmysql_select_db('myschema');? - Funk Forty Niner