Connect in mysql without pdo or mysqli;

60 views
Skip to first unread message

SPED MAKER

unread,
Jun 5, 2017, 3:48:37 PM6/5/17
to Google App Engine
Guys, I'm having difficulties with connecting to SQL .....
Has anyone succeeded in making a mysql_pconnect or mysql_connect connection?

If so, how did you achieve this feat?

If not, join me to cry together.

Yannick (Cloud Platform Support)

unread,
Jun 6, 2017, 9:39:05 AM6/6/17
to Google App Engine
I understand you’re trying to connect from a MySQL server from a PHP App Engine, is that correct? This guide in our documentation details how to connect to Cloud SQL (which is MySQL under the hood) from a PHP application. Is it lacking in some ways in regards to your needs?

SPED MAKER

unread,
Jun 6, 2017, 11:04:40 AM6/6/17
to Google App Engine
In this sample, the method used is PDO.
But on my system I using mysql_connect and mysql_query...And so forth.
I not would like change the query for connections methods.

I believe that problem to happens because the first parameter on mysql_connect ($server or socket)... how I should send this information ?

Very Thank

SPED MAKER

unread,
Jun 6, 2017, 4:29:40 PM6/6/17
to Google App Engine
i did two code to test :
1° have one query with  connection per PDO;
2° have a simple mysql_connection.

The firts it works, not  problem.
but the other have problems to connect.... 

to make a connection with mysql_query i use:
mysql_query($host,$user,$password) while in PDO i use a string like was suggested in the doc that you send;

how i can fill the $host to obtain success on my connection



SPED MAKER

unread,
Jun 7, 2017, 10:26:06 AM6/7/17
to Google App Engine
I solved this problem.

to connect with a mysql_connection is necessary a little change.

the example says to use:
  MYSQL_DSN: mysql:unix_socket=/cloudsql/INSTANCE_CONNECTION_NAME;dbname=DATABASE;

to make a connection with PDO.

in mysql_connect use this::

$server = ":/cloudsql/INSTANCE_CONNECTION_NAME";
$user = 'root'
$pass = "pass";

mysql_connect ($server,$user,$pass);


Yannick (Cloud Platform Support)

unread,
Jun 7, 2017, 10:29:05 AM6/7/17
to Google App Engine
I'm glad you were able to figure it out, thanks for coming back to post your findings!
Reply all
Reply to author
Forward
0 new messages