0

I have this error message:

Fatal error: Uncaught Error: Call to undefined function mysqli_connect()


My code is :

<?php
$localhost="localhost";
$root="root";
$password="";
$database="company";
$connectDB=mysqli_connect($localhost,$root,$password,$database);

i've checked these solutions down below in this website and other websites :

  • php(ini) in XAMPP and removing (;) before extension=mysqli and also the PDO extension.
  • i've uninstalled XAMMP and reinstalled it.
  • i've check this code on the other system and it was OK but unfortunately , not worked in my computer.

I don't know everybody has solved this problem by removing ; before the extensions but this is not working in my system!

this is a super simple code but with a big bug (LOL)

silva
  • 1
  • 1
  • It's not `new mysqli()` which have to be used, such as mentionned here: https://www.php.net/manual/en/mysqli.quickstart.connections.php ? – Elikill58 Jul 17 '21 at 21:58
  • Yes. you need to install and activate the mysqli extension. And yes, this normally works by removing the `;` in the ini before the extension loading directive. – hakre Jul 17 '21 at 21:58
  • @Elikill58: No, it's Procedural style as mentioned here: https://www.php.net/manual/en/mysqli.construct.php - the **mysqli** class would not be there, like the function. – hakre Jul 17 '21 at 21:59

1 Answers1

1

After removing ; before extension=mysqli you should restart your Web server Also check in php.ini extension_dir= your extensions dir if this doesn't work Create a new php file and type in it

echo phpinfo();

And check if loaded configuration file = your php.ini dir if not

Go to apache config file httpd-xampp.conf and type in the end of the file

PHPIniDir "C:/path_to_xampp/php/php.ini"

After that restart apache and should work fine

Omar Khaled
  • 66
  • 1
  • 9