Linked Questions

Popular Questions

I'm working on a slim api using and I have reinstalled the project several times and recreated the everything. I'm getting error on line 15 of my index.php file. this is the error

Fatal error: Uncaught RuntimeException: Unexpected data in output buffer
Notice: Undefined variable: db in /var/www/html/slimquote/index.php on line 15

Fatal error: Uncaught RuntimeException: Unexpected data in output buffer. Maybe you have characters before an opening <?php tag? in /var/www/html/slimquote/vendor/slim/slim/Slim/App.php:625 Stack trace: #0 /var/www/html/slimquote/vendor/slim/slim/Slim/App.php(335): Slim\App->finalize(Object(Slim\Http\Response)) #1 /var/www/html/slimquote/index.php(22): Slim\App->run() #2 {main} thrown in /var/www/html/slimquote/vendor/slim/slim/Slim/App.php on line 625

I have removed and search for any character before the opening tag Still I keep getting this error. does anyone know what this is?.. I have search all over, and everyone points to closing tags ?>, but I have none left. I have also commented out any line including database configuration and anything instantiating a database... any help appreciated. index.php file

<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);

use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require 'vendor/autoload.php';
//require 'dbHandlers/DBconnection.php';

//$conn = new DBconnection();
//$db = $conn->dbConnect();

$app = new \Slim\App;
$app->get('/', function (Request $request, Response $response, array $args) {
//  $query = 'SELECT * FROM quotes_tb ORDER BY id';
//  $sql = mysqli_query($db, $query);   

    $response->getBody()->write("Hello world");
    return $response;
});
$app->run();

Related Questions