my php script is working fine in GAE but not on the server

167 views
Skip to first unread message

help

unread,
Sep 25, 2015, 5:21:23 PM9/25/15
to Google Cloud SQL discuss
my php script is working fine in GAE but not on the server. If i run this script on my computer it is working fine , cloud sql database is also updated but this script is not working on cloud. Show error :- Could not get data: Unable to find the socket transport "unix" - did you forget to enable it when you configured PHP?







script is as follow :-


<?php
   
$conn = mysql_connect('173.194.249.431',
  'anurag', // username
  'sdsdsZcz'      // password
  );
if ($conn)
{
echo "connection established";
}
$checkdb = mysql_select_db('test');
if ($conn)
{
echo "database connected";
}
$sql = "INSERT INTO test (name) VALUES (123)";
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not get data: ' . mysql_error());
}
echo "successfully done ";
?>

David Newgas

unread,
Sep 25, 2015, 5:34:24 PM9/25/15
to Google Cloud SQL discuss
Hi,

As documented, when connecting from Google App Engine to Google Cloud SQL you should not connect by IP, instead you should connect to a socket at /cloudsql/<your-project-id>:<your-instance-name> (normally with username 'root' and blank password).

Yours,
David

--
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-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/d1eeea7b-8816-4ea0-9fbf-615b125adc8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

help

unread,
Sep 25, 2015, 5:51:25 PM9/25/15
to Google Cloud SQL discuss
it is still showing the same error. 

error message :-  Could not get data: Unable to find the socket transport "unix" - did you forget to enable it when you configured PHP?
 
<?php
    echo 'Hello world!';

$conn = mysql_connect('/cloudsql/testingqweqwe:gh', 
  'root', // username
  ''      // password

David Newgas

unread,
Sep 25, 2015, 5:59:25 PM9/25/15
to Google Cloud SQL discuss
I believe if you are using mysql_connect you need to prepend ':' to the socket. So you should use:

$conn = mysql_connect(':/cloudsql/<your-project-id>:<your-instance-name>',

 
'root', // username
 
''      // password
 
);

mysql_select_db
('<database-name'>);
As shown in our documentation.

--
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-d...@googlegroups.com.

help

unread,
Sep 25, 2015, 6:07:34 PM9/25/15
to Google Cloud SQL discuss
thanks a lot bro...
now my script is working fine 
Reply all
Reply to author
Forward
0 new messages