Salman
Salman

Reputation: 109

How to Connect to a Google Cloud SQL Instance from a Different Server

I need your help! I'm trying to connect to the Google Cloud SQL instance from a different server (ie.,provided through Hostgator) but I am unable to select the Database (which is already created at Google Cloud SQL) using the mySQL function - "mysql_select_db" in order to store and retrieve data from my application running at Hostgator webhost.

This is the error that I'm getting

mySQL error

Here's the code which am using

PHP code

Any help would be highly appreciated!!

Update

After correcting the mysql_select_db() function, I'm able to select and insert into the DB table but when I try to retrieve and count the number of rows in the table, I get the following warning

Warning

This is the code for the same

code

Here's the code used to insert the record

mysqli_query($con, "INSERT INTO members VALUES(32, 'Sallu')");

echo "Row inserted";

Thanks

Upvotes: 0

Views: 642

Answers (2)

You are using mysqli_connect but you want to select the database using mysql_select_db.

Upvotes: 1

Arun
Arun

Reputation: 760

Use mysqli_* statement

mysqli_select_db($conn,"testing");

mysqli_query("YOUR QUERY..",$conn)

Upvotes: 1

Related Questions