为什么我在mysqli_connect函数上不断收到此错误

时间:2019-02-05 23:06:22

标签: php mysqli slim

我有一个index.php,它是苗条api框架应用程序的一部分。当我包含mysqli_connect函数时,出现此错误。

Fatal error: Uncaught Error: Class 'mysqli_connect' not found in /home/zent/public_html/apps/slimpro/index.php:11 Stack trace: #0 {main} thrown in 

我删除了第11行,它是msyqli_connect函数,它可以正常工作。这是其余的index.php

<?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 'include/dbHandlers/dbConfig.php';

$conn = mysqli_connect(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
if(!$conn) {
        die("Connection failed! " . mysqli_connect_error());
}
else {
        echo "connection sucess!";
}

$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();

0 个答案:

没有答案