title: Connecting to Google Cloud SQL in Google App Engine
body: <p>Basically I am deploying an simple website that has register and login.
  I have deployed into AppEngine and my Cloud SQL is in the same AppEngine Project. Project: <a href="http://cc-lab4.appspot.com/register.php" rel="nofollow noreferrer">http://cc-lab4.appspot.com/register.php</a></p>
  
  <p>I created database and table in Cloud SQL, I want my register.php to connect to the cloud sql database and perform insert query. </p>
  
  <p>I really want to use mysqli_connect() since I am familiar with this, PDO connection is new to me.</p>
  
  <p>I don't know the exact way of connecting yet, havent been successfull at all.
  Anyone have idea how to use mysqli_connect() to Cloud SQL would be great.</p>
  
  <p>After Editing by using one of the answers, still didn't work:
  <a href="https://i.stack.imgur.com/e3wQN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e3wQN.png" alt="Cloud SQL Database Instance"></a></p>
  
  <pre><code> //Variables for Database connection
   $user = "root";
   $pw = "root";
   $socket = '/cloudsql/'. $ENV{"cc-lab4:australia-southeast1:my-sql-artworks"};
   $dbname = "artworks";
  
   //Registration values from &lt;Form&gt;
   $username = $_POST['username'];
   $password = $_POST['password'];
  
   //Database connection
   $db = mysqli_connect(NULL, $user, $pw, $dbname, NULL, $socket);
  
   if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
   }
  
   //Table Member (id, username,password,reg_date)
   $q = "insert into member values(null, '$username', SHA('$password'), now())";
   mysqli_query($db, $q); 
  </code></pre>