0

I am getting below error when trying to access from browser "http://192.168.x.x:9091/testcon.php"

Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/testcon.php

Contents of testcon.php is like below,

<?php
$servername = "db";
$username = "root";
$password = "pass1234";
$dbname='server';
$conn = mysqli_connect($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
 die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>

But the same is working from inside container. If i run like "php testcon.php" it will work

root@e951040c5265:/var/www/html# php testcon.php
Connected successfullyroot@e951040c5265:/var/www/html#

I have also edited /usr/local/etc/php/php.ini-development and uncommented line "extension=mysqli", Still facing same issue

docker images used are below,

mysql:8.0.1

php:7.4.7-apache

phpmyadmin/phpmyadmin

TIA

user3132525
  • 123
  • 6
  • 1
    did you restart apache after changing the php.ini ? – Vidal Jun 22 '20 at 11:46
  • Oh.Thanks a lot for mentioning. I have restarted apache now and everything is working fine. – user3132525 Jun 22 '20 at 12:03
  • You need to stop manually checking for errors. Please read: [Should we ever check for mysqli_connect() errors manually?](https://stackoverflow.com/q/58808332/1839439) and [Should I manually check for errors when calling “mysqli_stmt_prepare”?](https://stackoverflow.com/q/62216426/1839439) – Dharman Jun 22 '20 at 12:53

0 Answers0