<?php
define('DB_NAME', 'xp_database'); // DATABASE
define('DB_USER', 'valli'); // ROOT DEFAULT MYSQL
define('DB_PASSWORD', 'Valli123'); // PASSOWORD
define('DB_HOST', '127.0.0.1'); // LOCAL IF YOU USE LOCAL.
$data=array();
$i=1;
$link = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if($link === false)
{
die("ERROR: Could not connect. " . mysqli_connect_error());
}
else
{
echo "Connected to database";
}
// Attempt select query execution
$sql = "show databases";
if($result = mysqli_query($link, $sql))
{
if(mysqli_num_rows($result) > 0)
{
echo "<table>";
echo "<tr>";
echo "<th>userid</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['user_id'] . "</td>";
echo "</tr>";
// Free result
//set mysqli_free_result($result);
}
}
else
{
echo "No records matching your query were found.";
}
}
else
{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
?>
I have enabled the Admin API in google cloud. Connection is successful. But retrieval using select query is not successful. Please tell me what is missing in this. Is there any other setting that I have to do. I have migrated the data from local database to mysql cloud database.