I have created agent in API.AI and I have created a database in Google Cloud Platform. I am able to connect to it using Navicat Premium to update the database of the bot. Also, I am able to use webhook using Heroku with PHP scripting. And I'm able to get response successfully with this code below
<?php 
$method = $_SERVER['REQUEST_METHOD'];
// Process only when method is POST
if($method == 'POST'){
    $requestBody = file_get_contents('php://input');
    $json = json_decode($requestBody);
    $intent = $json->result->metadata->intentName;
    $entertype = $json->result->contexts->entertainmentType.original;
    $response = array(
                      "messages"=> [array(
                                       "type"=> 1,
                                       "platform"=> "facebook",
                                       "title"=> 'MBO Melaka Mall',
                                       "subtitle"=> 'Tingkat 2, Kompleks Melaka Mall, Lebuh Air Keroh, 75450 Melaka',
                                       "imageUrl"=> "http://s-yoolk-images.s3.amazonaws.com/my/gallery_images/medium/1435340336/67323?1435340336",
                                       "buttons"=> [ array(
                                                      "text"=> "Search in Google",
                                                      "postback"=>"https://www.google.com/search?q=mbo+melaka+mall&oq=mbo+melaka+mall&aqs=chrome..69i57j5.6761j0j7&sourceid=chrome&ie=UTF-8"
                                                  )
                                            ]
                                   )]
                        );
    echo json_encode($response);
}
else
{
    echo "Method not allowed";
}
?>
However, after I update this, I'm not able to get any response and I got error code 500 as internal server error. Please help me.
<?php 
$method = $_SERVER['REQUEST_METHOD'];
// Process only when method is POST
if($method == 'POST'){
    $requestBody = file_get_contents('php://input');
    $json = json_decode($requestBody);
    $intent = $json->result->metadata->intentName;
    $entertype = $json->result->contexts->entertainmentType.original;
    $username="root";
    $password="pass";
    $database="qwertytrek";
    $connection=mysql_connect("35.200.241.96",$username,$password);*/
    if(!$connection)
    {
        $speech = "No Connection";
    }
    else 
    {
        $speech = "Connected to Google";
    }
    $selectdb = mysql_select_db($connection,$database) or die("Unable to select database");
    if ($selectdb) 
    {
        //echo = "database selected";
    }
    echo json_encode($response);
}
else
{
    echo "Method not allowed";
}
function cybercafe($user)
{
}
?>
