错误
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/login.php:8 Stack trace: #0 {main} thrown in /var/www/html/login.php on line 8
代码
<?php
$servername = "172.17.0.2:3306";
$username = "mysql_user";
$password = "mysql_password";
$dbname = "invoice";
// Create connection
$conn = mysqli_connect($servername, $username, $password,$dbname);
?>
我从php:7.0-apache docker容器运行它,我已经使用以下命令安装了mysqli扩展:
docker-php-ext-install mysqli
docker-php-ext-enable mysqli
apachectl restart
我错过了什么?
答案 0 :(得分:1)
检查php extension_dir的路径是否正确。 如果它不正确或没有路径, 然后在php.ini中添加mysqli.so的绝对路径,
就我而言,mysqli.so位于/usr/local/lib/php/extensions/no-debug-non-zts-20151012
你必须添加,
extension = /usr/local/lib/php/extensions/no-debug-non-zts-20151012/mysqli.so
在你的php.ini中。